[Openmcl-devel] Type-of and positive/negative integers

Steven Nunez steve_nunez at yahoo.com
Thu Oct 24 00:13:53 PDT 2019


 CCL (1.11) has most-positive-fixnum of 1152921504606846975SBCL (1.5.6) has 4611686018427387903

However:
CL-USER> (subtypep 'fixnum 'integer)
T
T
CL-USER> 

so FIXNUM is a subtype of INTEGER, and it should be the type returned if the implementation is following the CltL2 guidelines if I'm understanding the type system correctly.
    On Thursday, October 24, 2019, 2:45:24 PM GMT+8, Daniel Kochmański <daniel at turtleware.eu> wrote:  
 
 Hey Steven,

What is the most-positive-fixnum on your implementation? I would suspect
that it is 1152921504606846975, so (INTEGER 0 1152921504606846975) is a
subtype of FIXNUM, hence it is more specific type.

Best regards,
Daniel

Steven Nunez writes:

> I've been stumped by trying to understand why:
> ? (type-of -3)
> FIXNUM
> ? (type-of 3)
> (INTEGER 0 1152921504606846975)
> ?
> return different types. I know that type-of is somewhat ill-defined, but in my reading of the spec, '3' should also be a fixnum, since it is between most-negative-fixnum and most-positive-fixnum. CLtL2 suggests that implementors return the most specific type, and that would also be fixnum. Steele later points out some flaws in the current specification of type-of. Both CCL and SBCL exhibit this behaviour.
> Two questions for the smart ones out there:
>    
>    - Is there something in the spec that I missed that makes type-of behave this way?
>    - Is there a way to do a type checking assertion for fixnums that works with both positive and negative integers? I am trying to optimize some numerical functions.  
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel


-- 
Daniel Kochmański ;; aka jackdaniel | Przemyśl, Poland
TurtleWare - Daniel Kochmański      | www.turtleware.eu

"Be the change that you wish to see in the world." - Mahatma Gandhi  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20191024/424fff73/attachment.htm>


More information about the Openmcl-devel mailing list