[M3devel] REFANY-keyed tables?

mika at async.caltech.edu mika at async.caltech.edu
Sun Mar 2 14:02:43 CET 2014

I just want to make an observation...

REFANY behaves the way the Green Book says it does.  There's not a word in
there about concurrent garbage collectors or bit-pattern representations

If a, b : REFANY and a = b then a and b point to the same object.

You can't apply ^ to REFANY.  The only thing you can do to a value beyond
= is narrow it to another type.  That's why there's no Hash for REFANY.
(Not because the garbage collector is implemented one way or another.)

Of course you can put REFANY in a list.  You can make as many copies in as
many places as you want and = will continue working.

The rest is implementation... 

I'm not saying there isn't a lot of implementation, or that the
implementation doesn't have to get clever about some things, but you
really don't need to think about the implementation to know what you
can and can't do with REFANY.  It's all in the Green Book.

I definitely would not suggest messing with the garbage collector because
you want to get something working with REFANY in a pure Modula-3 program.
It defeats the purpose of REFANY.

If you MUST hash a whole bunch of objects that have being REFANY as
their only thing in common I'd suggest using TYPECODE and registering
hash procedures for each type you're interested in.  This is a simple
enough thing that Modula-3's runtime "introspection" facilities more
than suffice.  (Those facilities are more limited than Java's, for mostly
good reasons.)


More information about the M3devel mailing list