[bitc-dev] Addition of DEFREPR
Swaroop Sridhar
swaroop.sridhar at gmail.com
Sun May 21 13:34:01 EDT 2006
Jonathan S. Shapiro wrote:
> I think that the following is a (small) counterexample to what you say:
>
> (defrepr dr
> ((tag swizzled unswizzled)
> d:double
> (tag left right)
> (case (swizzled (i:int32 j:int32))
> (unswizzled (b:bool)))
> (case ((swizzled left) (k:int32)))))
>
> [Note that the 'd' field has moved up between the tags. Also note that
> the (invariant ...) form was an error in the spec. Such forms have no
> special annotation.]
>
> Because in this case the constructor would be written:
>
> (dr swizzled 2.0 right 5 6 7)
>
> However, this may not actually be important, because the ordering
> between the tags and the values is independent. That is, the left to
> right sequencing of tag-ids must be preserved, and the left to right
> sequencing of values must be preserved, but (at least conceptually) we
> *could* decide that the following two constructor calls are equivalent
> in meaning to the one I gave above:
>
> (dr swizzled right 2.0 5 6 7)
> (dr 2.0 5 6 7 swizzled right)
Or, we can say that all constructor labels are collected to he beginning
and written as:
(dr#swizzled#right 2.0 5 6 7)
> However, I think this can only be rationalized if we define the tags to
> be some sort of label (i.e something other than expressions), because it
> violates the usual rules for application.
I think this is OK. In ML, constructors are treated specially from
normal application anyway (for example, they can appear in case
statements, but normal applications cannot).
>>In the above scheme, the case tags are scoped within the defrepr,
>>because they are always mentioned along with the defrepr's name. So, it
>>is as if we wrote these tags as dr-swizzled-right, etc, which are
>>guaranteed to be unique at top level. Right?
>
>
> I also thought that this could be made to work, but it has strange
> consequences. Consider:
>
> (let ((yes 1))
> (dr yes 2.0 left 5 6))
>
> where the intention is that this will turn into:
>
> (__con_dr-swizzled-right __tag_dr-swizzled-yes 2.0
> __tag-dr-direction-left 5 6)
>
The above scheme solved this problem as well.
(let ((yes 1))
(dr#swizzles#left 2.0 5 6))
Swaroop.
More information about the bitc-dev
mailing list