Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

reflection on type definitions

76 views
Skip to first unread message

Jim Newton

unread,
Dec 6, 2016, 12:28:44 PM12/6/16
to
I know there's no standard way in CL to find a type definition given a type,
but does each implementation have one?

For example if I evaluate

(deftype foo (x)
`(and string (satisfies ,x))

Can I find out that (foo bar) type-expands to (and string (satisfies bar)) ?

I'm using SBCL so having a way to do this in SBCL would be a big first step.

Jocelyn Fréchot

unread,
Dec 6, 2016, 12:49:17 PM12/6/16
to
On 06/12/2016 18:28, Jim Newton wrote:

> For example if I evaluate
>
> (deftype foo (x)
> `(and string (satisfies ,x))
>
> Can I find out that (foo bar) type-expands to (and string (satisfies bar)) ?

SB-EXT:TYPEXPAND and friends seems to be a good start point:

(typexpand '(foo bar))
=> (AND STRING (SATISFIES BAR))
=> T

--
Jocelyn Fréchot

Marco Antoniotti

unread,
Dec 6, 2016, 4:44:32 PM12/6/16
to
It is for SBCL. Not for, say, Allegro.

In LW you have

CL-USER 11 > (deftype foo (x)
`(integer 0 ,x))
FOO

CL-USER 12 > (type:expand-user-type '(foo 42))
(INTEGER 0 42)
T

Cheers
--
MA

Duane Rettig

unread,
Dec 9, 2016, 8:01:08 PM12/9/16
to
It's not standardized, so everyone has their own. In Allegro CL:

CL-USER(2): (deftype foo (x)
`(and string (satisfies ,x)))
FOO
CL-USER(3): (excl::deftype-expand '(foo bar))
(AND STRING (SATISFIES BAR))
CL-USER(4):

Duane
0 new messages