[M3devel] Resummary of tagged reference proposals
hendrik at topoi.pooq.com
hendrik at topoi.pooq.com
Tue Jun 2 12:31:52 CEST 2009
On Tue, Jun 02, 2009 at 10:04:37AM +1000, Tony Hosking wrote:
> The compiler and run-time support is already in the CVS head.
>
> On 1 Jun 2009, at 22:21, Darko wrote:
>
> >This is a great little hack. Is it available now or are you still
> >working on it? I don't know what other people want to use it for but
> >this is a great way to link memory structures with external data. It
> >overcomes one of the downsides of GC compared to say C, where you
> >can use pointer values for other purposes, but it does it safely.
> >
> >Also I'd like to add my voice for the minimalist approach where no
> >language changes are made. I don't think there is a semantically
> >clean way of incorporating this into the language and I'm not sure
> >there is any payoff in doing so.
I think there is a semantically clean way of incorporating it into the
language, but it's not a trivial change. It becomes an optimisable
special case of a more general feature -- for any bunch of types A, B,
C, ... you introduce a type UNION(A, B, C, ...). There's nothing you
can do with a union except build it from an A, B, or C ..., copy it, and
test its type and extract the contents -- more or less what you can do
to one of our type-tagged values. These unions have a fixed size (more
or less the max of the sizes of A, B, C, ... and an extra type-tag.
(I don't know if there has to be a restriction on using open arrays
here; I hole not.)
In the special case of UNION(A, B), where B is a suitable subrange if
INTEGER and A is a pointer-to-object, the compiler could choose to
implement this with our low-bit-and-shift hack.
-- hendrik
More information about the M3devel
mailing list