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,b47b15fda2aeb0b2 X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: Two ideas for the next Ada Standard Date: 1996/09/06 Message-ID: #1/1 X-Deja-AN: 178872836 references: <50aao3$3r88@news-s01.ny.us.ibm.net> <50gelc$2le@goanna.cs.rmit.edu.au> <50jk0f$krh@goanna.cs.rmit.edu.au> <50opma$kos@goanna.cs.rmit.edu.au> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-09-06T00:00:00+00:00 List-Id: Richard said "That's one of the things I like about the old Russell type system: you can derive a new type by weakening. I can say "T is integer except that it doesn't have these operations." >This includes add, multiply, subtract, 'Image, and all the >other built in stuff, That is indeed a weakness in Ada. It should be possible to exclude such things. It is presently possible to do that by exporting a private type and replicating all and only the things I _do_ want to offer, so I don't call it a defect." Richard, you can't quite do 100% of what you want, since you cannot exclude attributes like Image, but you are obviously missing an important capability in Aa 95. type x is range 1..10; function "+" (a,b : x) return x is abstract; causes the addition operator to be unavailable for this type. This is how weakening is done in Ada 95. In general it is a good idea to turn any statement of the form "You cannot do xxx in Ada 95" to a question "How do you do xxx in Ada 95?" unless you are very sure of your facts. That way you avoid stating misconceptions as facts on the newsgroups. It's an interesting point that it is a pity that there is no way to suppress attributes. That's particularly true in the floating-point case, where there are huge numbers of attributes, or in the enumeration type case, where it would be nice to suppress Pos, Succ, and Pred. The other operation that you cannot suppress is the ability to take subranges, which, particularly in the enumeration type case, can be unfortunate. The reason is that it allows clients to depend on the order of items in the enumeration definition, which is really the business of the defining package. You can supppress the comparison operations, but not the IN and NOT IN operations on user defined subtypes, which are essentially semanticaly equivalent to the comparison operations.