[pro] "fhash"

Raymond Wiker rwiker at gmail.com
Tue Jun 14 18:10:18 UTC 2011


On Jun 14, 2011, at 19:48 , Zach Beane wrote:

> Raymond Wiker <rwiker at gmail.com> writes:
> 
>> On Jun 14, 2011, at 19:30 , Martin Simmons wrote:
>> 
>>>>>>>> On Tue, 14 Jun 2011 09:32:50 -0400, Daniel Weinreb said:
>>>> 
>>>> But Fare pointed out to me that being able to add generic functions
>>>> specialized on these would be a good thing.  This would mean making them use
>>>> CLOS not for encapsulation but for genericty.
>>> 
>>> Use can specialize methods on defstruct classes too, so they don't have to be
>>> CLOS instances defined with defclass.
>> 
>> Built-in classes too[1], which means that you can have methods
>> specialized on (e.g.) single-float and double-float, fixnum and
>> bignum, list and vector, etc.
> 
> Well, only if those types also happen to have a corresponding
> implementation-specific class. SINGLE-FLOAT, DOUBLE-FLOAT, FIXNUM, and
> BIGNUM are specified as types. LIST and VECTOR are system classes. FLOAT
> is also a system class.
> 
> I recently ran into some accidentally unportable code that specialized a
> method argument on DOUBLE-FLOAT. It worked in SBCL but failed in CLISP
> because CLISP provides no DOUBLE-FLOAT class.

You're right - looks like I should have spent a little time on looking things up (again) :-)

CLTL2 lists (table 28-1, page 846) a number of predefined types with their class precedence lists. This table includes things like float, rational, integer and complex, but not things like single-float, double-float. Sooo, it *is* possible to specialize on built-in types, but not necessarily on *all* of them.







More information about the pro mailing list