Prev: Buy Rakhi & Kanthi for Lord Ganesh & Durga
Next: setting up emacs super and hyper keys (tutorial)
From: Joshua Taylor on 7 Aug 2010 10:46 I've recently come across some generic function definitions in some library code that include a default method that signals an error. The defgeneric forms are analogous to the following. (defgeneric frob-bar (frobber bar) (:method (frobber bar) (error "No frob-bar method for ~a and ~a." frobber bar))) If there were no method definition in this defgeneric, then the default method would call no-applicable-methods whose default method signals an error (of type error). Is there any benefit to the approach I'm seeing in this library? The error message here isn't likely to be more useful than what would be provided by no-applicable-methods, so I don't expect that that's the rationale. This approach also circumvents no-applicable-method's machinery (since there will always be an applicable method), but that seems more like an inconvenience than a benefit. Are there good reasons for providing such a default method? //JT
From: Pascal J. Bourguignon on 7 Aug 2010 11:03 Joshua Taylor <tayloj(a)cs.rpi.edu> writes: > I've recently come across some generic function definitions in some > library code that include a default method that signals an error. The > defgeneric forms are analogous to the following. > > (defgeneric frob-bar (frobber bar) > (:method (frobber bar) > (error "No frob-bar method for ~a and ~a." frobber bar))) > > If there were no method definition in this defgeneric, then the default > method would call no-applicable-methods whose default method signals an > error (of type error). Is there any benefit to the approach I'm seeing > in this library? The error message here isn't likely to be more useful > than what would be provided by no-applicable-methods, so I don't expect > that that's the rationale. This approach also circumvents > no-applicable-method's machinery (since there will always be an > applicable method), but that seems more like an inconvenience than a > benefit. > > Are there good reasons for providing such a default method? I'd be the reason is that the programmer was used to other OO programming languages where nothing like no-applicable-methods exists, and he didn't know yet about no-applicable-methods. Whether this is a good reason remains to debate... -- __Pascal Bourguignon__ http://www.informatimago.com/
From: Zach Beane on 7 Aug 2010 11:52 Joshua Taylor <tayloj(a)cs.rpi.edu> writes: > I've recently come across some generic function definitions in some > library code that include a default method that signals an error. The > defgeneric forms are analogous to the following. > > (defgeneric frob-bar (frobber bar) > (:method (frobber bar) > (error "No frob-bar method for ~a and ~a." frobber bar))) I recently did something like that in a GF where I found the no-applicable-method error too obscure and confusing for my target audience. The message was more application-specific than "No frob-bar method ..." - it was more like "This application is not supported on your configuration." Zach
|
Pages: 1 Prev: Buy Rakhi & Kanthi for Lord Ganesh & Durga Next: setting up emacs super and hyper keys (tutorial) |