[closer-devel] Recursive types

Marco Antoniotti marcoxa at cs.nyu.edu
Tue Jul 22 10:12:37 UTC 2008


On Jul 21, 2008, at 18:35 , Pascal Costanza wrote:

>
> On 21 Jul 2008, at 17:04, Marco Antoniotti wrote:
>
>>
>> On Jul 13, 2008, at 17:54 , Pascal Costanza wrote:
>>
>>> As far as I can tell, a modification of deftype should be  
>>> sufficient, such that (deftype name) "announces" a type without  
>>> saying yet what it will be.
>>>
>>> Maybe write a first draft of such a CDR, and then ask the vendors  
>>> what they think, they should know best whether and where this  
>>> hurts...
>>
>> That is my intention.  However, just modifying DEFTYPE already  
>> raises issues.  See the following...
>>
>> (deftype foo)
>>
>> (deftype bar)
>>
>> (deftype foo-or-bar () '(or foo bar))
>>
>>
>> Now, all these types are actually "empty" from a set-theoretic  
>> point of view.
>
> Hm, well, my idea was that (deftype foo) only "announces" the type  
> foo but doesn't define it yet, so that you can do things like this:
>
> (deftype arc) ;; not yet defined, but tells the compiler that it  
> will be defined later
>
> (defstruct node
>   content
>   (left nil :type (or null arc))
>   (right nil :type (or null arc))
>
> (defstruct arc ;; now it is defined as a struct
>   (source nil :type (or null node))
>   (sink nil :type (or null node)))
>
> The tricky part is in (a) specifying where an announced but not yet  
> defined type is allowed to be used and (b) specifying what is the  
> latest point in time when an announced type must effectively be  
> defined (like, for example, performing the first type test with the  
> given type - it's unclear to me what the most adequate criterion  
> should be here).

Yes.  All of these issues should be cleared.



>
>> Also, note the following interesting behavior on LWM and ACL 8.1 (I  
>> have not tested other implementations).
>>
.....
>>
>> AFAIAC this is not good.   And the culprit is the DEFTYPE that does  
>> introduce an extra namespace in CL without really defining what is  
>> in there and how I can manipulate it.
>
> Why? You got what you asked for. (deftype gnoa ()) has an empty  
> body, so by default it returns nil, which happens to be the type  
> that doesn't have any instances.
>
> Furthermore, ANSI CL doesn't say anything about type redefinition,  
> so we are in unspecified realm here. ANSI CL only says something  
> about class redefinition, but that doesn't change the corresponding  
> types.

Yes.  We are in "evil country" (i.e. unspecified behavior or  
implementation dependent).  So you see that the issue is not all that  
easy to fix.  I'll submit this to LW and Franz and hear what they say.


--
Marco Antoniotti





More information about the closer-devel mailing list