Subject: Re: It's A Big Language Survey
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 29 Apr 2009 04:16:13 -0500
Newsgroups: comp.lang.lisp
Message-ID: <PJidnaICnYJAh2XUnZ2dnUVZ_j-dnZ2d@speakeasy.net>
GP lisper  <spambait@clouddancer.com> wrote:
+---------------
| <pc@p-cos.net> wrote:
| > Kenneth Tilton wrote:
| >> Lisp G*ds Only, for reasons obvious:
| >> What is/are the big chunks of CL you have never used? 
| >
| > I have never used the numerical tower.
| 
| Tower???
+---------------

(*sigh*) Kids these days...  ;-}

    http://en.wikipedia.org/wiki/Numerical_tower
    Numerical tower

    In Scheme and some other Lisp dialects, a numerical tower is the set
    of data types that represent numbers in a given programming language.

    Each type in the tower conceptually "sits on" a more fundamental type,
    so an integer is a rational number and a number, but the inverse
    is not necessarily true, i.e. not every number is an integer; this
    asymmetry implies that a language can allow implicit coercions of
    numerical types - without creating semantic problems - in only one
    direction:  ...

And as usual, CL is more a "ball of mud" than Scheme...  ;-}

The CLHS doesn't use the term "numerical tower" per se, but CL's
numerical tower is implicit in the class precedence lists of its
numeric types [though the "purity" of the class tower is marred
slightly by a few mild restrictions on the COMPLEX and RATIO classes]:

    - t
      - number
	- complex   ; includes #c(real 0.0) but excludes #c(rational 0)
	- real
	  - float
	    - short-float
	    - single-float
	    - double-float
	    - long-float
	  - rational
	    - ratio ; n/d, (and (not (zerop n)) (plusp d) (= (gcd x y) 1))
	    - integer
	      - fixnum
	      - bignum

Also note that while UNSIGNED-BYTE, & SIGNED-BYTE are subtypes of
INTEGER, such values of such types can be in either class FIXNUM
or BIGNUM, so that {UN,}SIGNED-BYTE are *not* "classes" per se,
and thus are not in any of the numeric class precedence lists.
[The CLHS uses a list of Supertypes for these, instead.] Which
also means that, contrary to what one might otherwise expect, BIT,
as a subtype of UNSIGNED-BYTE, is not a sub-*class* of FIXNUM.
That is, while CL's numeric *classes* are a tree, its numeric
*types* are a DAG.


-Rob

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