[armedbear-devel] BigNum question

archisman rudra archi.rudra at gmail.com
Tue Oct 9 19:44:20 UTC 2012


Ah, I see. There is freedom on the part of implementations here.

thanks

On Tue, Oct 9, 2012 at 3:36 PM, Alan Ruttenberg <alanruttenberg at gmail.com>wrote:

>
>
> On Tue, Oct 9, 2012 at 2:34 PM, archisman rudra <archi.rudra at gmail.com>wrote:
>
>> Is this correct behavior?
>>
>> CL-USER(17): (type-of 1234567898723618080928927362387)
>> (INTEGER 2147483648)
>>
>>
>>
>> The relevant java code is in Bignum.java: (the value field is a java
>> BigInteger)
>>
>>   @Override
>>   public LispObject typeOf()
>>   {
>>     if (value.signum() > 0)
>>       return list(Symbol.INTEGER,
>>                    new Bignum((long)Integer.MAX_VALUE + 1));
>>     return Symbol.BIGNUM;
>>   }
>>
>>
>>
>> for comparison:
>> CL-USER(23): (type-of -1234567898723618080928927362387)
>> BIGNUM
>>
>>
>> which makes intuitive sense.
>>
> http://www.lispworks.com/documentation/lw51/CLHS/Body/f_tp_of.htm
>
> *Relevant bits of type-of description:*
>
> Returns a *type specifier*<http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_t.htm#type_specifier>
> , *typespec*, for a *type*<http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_t.htm#type> that
> has the *object* as an *element*<http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_e.htm#element>.
> The *typespec* satisfies the following:
>
> 1. For any *object* that is an *element*<http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_e.htm#element> of
> some *built-in type*<http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_b.htm#built-in_type>
> :
>
> a. the *type*<http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_t.htm#type> returned
> is a *recognizable subtype*<http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_r.htm#recognizable_subtype> of
> that *built-in type*<http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_b.htm#built-in_type>
> .
>
> b. the *type*<http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_t.htm#type> returned
> does not involve and, eql, member, not, or, satisfies, or values.
>
> 3. The *type*<http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_t.htm#type> returned
> by *type-of*<http://www.lispworks.com/documentation/lw51/CLHS/Body/f_tp_of.htm#type-of> is
> always a *recognizable subtype*<http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_r.htm#recognizable_subtype> of
> the *class*<http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_c.htm#class> returned
> by *class-of*<http://www.lispworks.com/documentation/lw51/CLHS/Body/f_clas_1.htm#class-of>.
> That is,
>
>  (subtypep (type-of object) (class-of object)) =>  true <http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_t.htm#true>, true <http://www.lispworks.com/documentation/lw51/CLHS/Body/26_glo_t.htm#true>
>
>
> So my read is that there's no guarantee of literal repeatability between
> the returned values of type-of even in subsequent calls, never mind between
> implementations.
>
> -Alan
>
>
>
>>
>>
>>
>>
>>
>> _______________________________________________
>> armedbear-devel mailing list
>> armedbear-devel at common-lisp.net
>> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20121009/c5f8b6f0/attachment.html>


More information about the armedbear-devel mailing list