comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Q: unboxed values and polymorphism
Date: 1996/06/22
Date: 1996-06-22T00:00:00+00:00	[thread overview]
Message-ID: <dewar.835455280@schonberg> (raw)
In-Reply-To: DtEHCE.34x@world.std.com


Robert Duff said

"And the pointer would be 31 bits, so the whole thing fits in 32?  Quite
reasonable, except that I've never heard of an Ada compiler that can
support that kind of packing.  Certainly, the RM does not require
support for that sort of packing."

It does not need to be a pointer, it can be an index, or simply an 
encoded pointer (you can certainly encode the pointer). I still prefer
the abstraction of a variant record here, although I agree that if you
hide the low level representation under the covers it does not matter
that much.

If you use the approach of a pointer with its low order bit fudged to
flag the integer case (i.e. the hardware structure used on the Sparc),
then you still have to do unchecked mucking to get the pointer anyway.

So it seems to me preferable to encode the pointer in 31 bits, and the
discriminant in 1 bit. You need to do equivalent unchecked mucking to
encode the pointer, but the structure is still preferable.

P.S. in assembly language, I usually use a slightly different approach here
of putting the flag bit in the sign bit and having the remainder of the
word be the pointer divided by two. That way you should the whole word
left one bit, and the flag is now in the carry bit, and the pointer is
correct in the register. You can actually persuade gcc to generate code
that is equivalent if you are VERY careful to state things right (that's
an odd style of code which happens some times, really you are writing
assembly language, but you are forced to play a delicate balancing game
between some high level language and its optimizing compiler -- not the
sort of thing one generally wants to encourage :-)





  reply	other threads:[~1996-06-22  0:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-15  0:00 Q: unboxed values and polymorphism Hannes Haug
1996-06-15  0:00 ` Robert Dewar
1996-06-15  0:00 ` Jon S Anthony
1996-06-16  0:00 ` Hannes Haug
1996-06-17  0:00   ` Hannes Haug
1996-06-18  0:00     ` Fergus Henderson
1996-06-18  0:00     ` Robert Dewar
1996-06-22  0:00       ` Robert A Duff
1996-06-22  0:00         ` Robert Dewar [this message]
1996-06-17  0:00   ` Tucker Taft
1996-06-17  0:00   ` Tucker Taft
1996-06-17  0:00     ` Tucker Taft
1996-06-22  0:00   ` Hannes Haug
1996-06-22  0:00     ` Robert Dewar
     [not found]       ` <uvvhgryr22d.fsf@chaq.informatik.uni-tuebingen.de>
1996-06-28  0:00         ` Robert Dewar
1996-07-02  0:00           ` Fergus Henderson
1996-06-18  0:00 ` Jon S Anthony
1996-06-19  0:00 ` Hannes Haug
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox