Subject: Re: Differences between types
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 20 Feb 2009 07:33:54 -0600
Newsgroups: comp.lang.lisp
Message-ID: <WdSdnWIhI5PfLAPUnZ2dnUVZ_uidnZ2d@speakeasy.net>
jurgen_defurne  <jurgen.defurne@pandora.be> wrote:
+---------------
| When I do the following :
| 
| [4]> (type-of 13000)
| (INTEGER 0 16777215)
| [5]> (type-of 4294967295)
| (INTEGER (16777215))
| 
| If I look at the CLHS, I understand that the first one is an integer
| between 0 and 16777215.
+---------------

Caution: This is somewhat implementation-dependent.
E.g., CMUCL always shows the types of integers this way:

    cmu> (type-of 13000)

    (INTEGER 13000 13000)
    cmu> (type-of 4294967295)

    (INTEGER 4294967295 4294967295)
    cmu> 

This is not unreasonable in an implementation with a compiler with
type propagation, since integers are immutable and therefore both
the lower and upper ranges of the type can legally be described as
the integer itself. Note that this is the *most*-specific possible
type for an integer. CMUCL also recognizes less-specific types, of
course:

    cmu> (subtypep (type-of 13000) 'fixnum)

    T
    T
    cmu> (subtypep (type-of 4294967295) '(integer 4294967290 4294967299))

    T
    T
    cmu> (subtypep (type-of 4294967295) '(integer 0 18446744073709551615))

    T
    T
    cmu> 


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607