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: Hannes Haug Subject: Re: Q: unboxed values and polymorphism Date: 1996/06/16 Message-ID: #1/1 X-Deja-AN: 160462949 sender: haugha@chaq.informatik.uni-tuebingen.de references: organization: Uni Tuebingen newsgroups: comp.lang.ada Date: 1996-06-16T00:00:00+00:00 List-Id: >>>>> "Jon" == Jon S Anthony writes: Jon> In article Jon> Hannes Haug writes: >> I'm new to Ada and have a questions on polymorphism. The >> standard way to have polymorphism in Ada are tagged >> records. But for my needs Jon> If it helps, it also works this way in C++, Eiffel, Sather, Jon> and any other "statically" typed OO language. >> this requires too much space. Jon> Then you are in trouble no matter what. But the trouble is not that big. >> require too much time and space. I'd like to convert access >> values to integers and do my own tagging. I could simply >> translate my C code. Jon> This sounds like a _really_ _really_ bad idea. In your C, Jon> are you using "meta" bits (ala' Lisp impls) or what? Sort of. Fixnums are integers in the range -2^30 ... 2^30-1. Other integers are interpreted as pointers to (or indices in arrays of) bignums or list cells. And it is not a bad idea. >> But it would be nice to see how an experienced Ada programmer >> would do this in Ada. Can I find some code that does this >> somewhere ? Jon> I'm not sure what it is you are trying to do. Make a list? Jon> Make a generic list? Make a typed polymorphic list? Make an Jon> untyped uncheckd programmer beware list? What? I need it for my computer algebra nucleus. I need lisp-like dynamic typing. I cannot use tagged records. This would make a list cell 50% bigger. This would mean 33% less list cells. And this would mean 50% more garbage collections. I also need the type information on the stack for my garbage collector. I cannot use records for fixnums either. This would mean a "new" for every operation. My nagation takes ca. 20 nsec for fixnums on a 90MHz hyperSPARC. With a "new" this would be a not so little bit slower. Perhaps the usage of records for fixnums would even make some functions too big for inlining. - hannes