From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8de933d44255f226 X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: Q: unboxed values and polymorphism Date: 1996/06/22 Message-ID: #1/1 X-Deja-AN: 162240296 references: organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-06-22T00:00:00+00:00 List-Id: 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 :-)