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,fc8cef2534e95561 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: 'Digit is generic package Date: 1996/08/29 Message-ID: #1/1 X-Deja-AN: 177315704 references: <4vj3e6$hi1@goanna.cs.rmit.edu.au> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-08-29T00:00:00+00:00 List-Id: In article <4vj3e6$hi1@goanna.cs.rmit.edu.au>, Richard A. O'Keefe wrote: >(a) I would get some consolation from knowing whether this was an *intended* > restriction for Ada 95 and if so what harm would have resulted had this > restriction not been in the language. This restriction comes from Ada 83, and as far as I know, nobody wanted to change it for Ada 9X. I recall some earlier version of Ada 83 (Ada 80, or Green, or something) was more liberal, along the lines you're asking for. I don't remember the exact rules, but I think it was possible to say things like "type T is digits X;" where X was a generic formal parameter. You could look at the old pre-1983 documents... The reason for the rule is essentially just to keep things simple, I think. It would be more complicated to describe a rule that allowed some expressions to be static, depending on knowing that they will be static in the instance. And it would probably be harder to implement. Also, if you allowed what you want in a generic body, then it would violate the contract model, and cause trouble for code-sharing implementations. In general, the definition of "static expression" was never intended to be "any expression that can be evaluated at compile time" -- just a reasonably useful, but not-too-hard-to-implement subset of those expressions. For example, composite expressions are never static in Ada 83, and in Ada 95, are static only in some severely-restricted string cases. >(b) Is there any better approach for doing this with a procedure than the > make-to-instances-and-pick-one-at-runtime one shown above? I think your best bet is to pass in three types, and check at run time that their 'Digits have the right relationship. That's not *so* awful. - Bob