From: Marco Antoniotti
Subject: Expanding a derived type spec
Date: 
Message-ID: <gLPDe.5$DJ5.59830@typhoon.nyu.edu>
Hi

I am pretty sure this is not standardized.

Suppose I have

(deftype non-negative-integer ()
   '(integer 0 *))

or

(deftype square-matrix (n)
   `(array * (,n ,n))

How do I get the "expansion" of NON-NEGATIVE-INTEGER or of
(SQUARE-MATRIX 3) in different Lisp implementations?

Cheers
--
Marco

From: Duane Rettig
Subject: Re: Expanding a derived type spec
Date: 
Message-ID: <4wtnk6rpt.fsf@franz.com>
Marco Antoniotti <·······@cs.nyu.edu> writes:

> Hi
> 
> I am pretty sure this is not standardized.
> 
> Suppose I have
> 
> (deftype non-negative-integer ()
>    '(integer 0 *))
> 
> or
> 
> (deftype square-matrix (n)
>    `(array * (,n ,n))
> 
> How do I get the "expansion" of NON-NEGATIVE-INTEGER or of
> (SQUARE-MATRIX 3) in different Lisp implementations?

In Allegro CL, starting with 7.0, you can use excl:normalize-type
(there was a "type-canonicalize" in prior versions, but it was
not exported nor supported):

CL-USER(1): (deftype square-matrix (n)
   `(array * (,n ,n))
)
SQUARE-MATRIX
CL-USER(2): (normalize-type '(square-matrix 3))
(ARRAY * (3 3))
CL-USER(3): 

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Kent M Pitman
Subject: Re: Expanding a derived type spec
Date: 
Message-ID: <uwtnkw1c7.fsf@nhplace.com>
Marco Antoniotti <·······@cs.nyu.edu> writes:

> Hi
> 
> I am pretty sure this is not standardized.
> 
> Suppose I have
> 
> (deftype non-negative-integer ()
>    '(integer 0 *))
> 
> or
> 
> (deftype square-matrix (n)
>    `(array * (,n ,n))
> 
> How do I get the "expansion" of NON-NEGATIVE-INTEGER or of
> (SQUARE-MATRIX 3) in different Lisp implementations?

There's no standard way.

If it's just your own code you want to do this for, one clumsy workaround
is to make a DEFINE-TYPE macro that expands into both a DEFTYPE and 
also something that saves away the expansion info for you to call separately.
This works for a variety of situations like getting the slots of a DEFSTRUCT,
etc.