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,a3ca574fc2007430 X-Google-Attributes: gid103376,public X-Google-Thread: 115aec,f41f1f25333fa601 X-Google-Attributes: gid115aec,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Ada and Automotive Industry Date: 1996/11/15 Message-ID: #1/1 X-Deja-AN: 196786124 references: <3280DA96.15FB@hso.link.com> <1996Nov6.210957.3070@ole.cdac.com> <1996Nov8.183051.21638@ole.cdac.com> organization: New York University newsgroups: comp.lang.ada,comp.realtime Date: 1996-11-15T00:00:00+00:00 List-Id: James said "That's not how I remember it. The ".." operator required that both of it's arguments be of the same "type" (the Ada LRM probably used another term) and -1 was considered an expression, but 1 wasn't. I prefer a language where if I write a statement that looks like it should be legal it is. Even PASCAL accepts for i:= 1- to 1 do ... " That's faulty memory. The exact situation is as follows. Of course both bounds have to be the same type, that goes without saying and is irrelevant to this discussion. The issue is what to do if there is no type in sight. Obviously a loop cannot use the type universal integer (if it did, there would be precious little you could do with the loop index!) So, if we write for j in 1 .. 10 loop the question is, what type to choose, since this is obviously ambiguous in most circumstances. The proper answer would have been to reject this as illegal, but in what many people feel in retrospect was a misguided effort to allow a simple notation for "do something ten times", a very restricted case was allowed where the type was implicit, namely the rule that if both bounds are integer literals, then type integer is assumed. As long as people understand that this is really jjust intended for the "do it ten times" case, this is not so horrible. After all in real programs, you do not use type Integer in any case, so defaulting to integer is only useful for this limited case. However, in practice (and this is why the exception was a bad idea), people DO use type Integer, and then they end up using this short hand. Of course they should write: for j in Integer range 1 .. 10 loop but they are lazy :-) Once they get into this lazy mode, they then expect for j in -1 .. +1 loop to work, but probably it's an even worse idea to allow this, because it generates confusion as to what operator is used, remember that -1 is not a literal, this is true in all languages I know, but rather an expression, so it makes a big difference what minus you use. For my taste it was a mistake to ever allow this abbreviated notation in the first place, and an important Ada style rulle is NEVER take advantage of this notation if the loop variable is referenced, and only use it for the "do it N times" with a lower bound of 1. As for the comment that things should do what is expected, yes, everyone agrees with this in principle, but the trouble is that, among people who know Ada well but not perfectly, there can be real confusion over which negation operator is used. it is much better that something be illegal than that you have a situation where two people say "ah, nice, this is legal, I would hope so, since it's obvious what it does", when unforunately they have different ideas about what the obvious meaning is!