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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,25aa3c7e1b59f7b5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-10 13:23:07 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newspeer.radix.net!uunet!ash.uu.net!world!news From: Robert A Duff Subject: Re: A case where Ada defaults to unsafe? Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Thu, 10 Jan 2002 21:22:05 GMT References: <3C34BF2C.6030500@mail.com> <3C34D252.4070307@mail.com> <0pkZ7.3899$cD4.6730@www.newsranger.com> NNTP-Posting-Host: shell01.theworld.com Organization: The World Public Access UNIX, Brookline, MA X-Newsreader: Gnus v5.7/Emacs 20.7 Xref: archiver1.google.com comp.lang.ada:18743 Date: 2002-01-10T21:22:05+00:00 List-Id: Ted Dennison writes: > In article , Robert A Duff says... > >If you're looking for cases where Ada makes the default less safe, I can > >think of a few. Here's one: "X: T := ...;" is a variable, whereas > >"X: constant T := ...;" is a constant. IMHO, it should be the other way > >around ("X: var T := ...;" for a variable), since constants are safer > >than variables. > I think this is another example of the *real* design principle here, > which is to make the more common and more general form take the least > syntax, and use added syntax to specify a more constrained and/or less > common form. I do not agree with that design principle. The default should be the thing that is safer/less-powerful. To use the more-powerful/more-dangerous option should require extra syntax. What's more common is irrelevant. Of course, one hopes that the safer thing is also the most common thing. For example, if programmers have to do type conversions or unsafe casts on every other line of code, then something is wrong with the language design -- whether those casts are explicit or implicit. So in practise, your principle will often come up with the same answer as mine. Many Ada programs use variables where they should use constants. Making the default the other way around (i.e. not punishing the safer case with verbosity) would somewhat alleviate that problem. The choice of "variable by default, constant requires explicit notation" is particularly annoying to me because it is inconsistent: for parameters, it's the other way 'round. An interesting question is whether variables are more common than constants in Ada. I have no idea. If you adopt a "mostly functional" style, you'll have a lot of constants... > If I try real hard I can come up with reasons why just about any > design decision might have error-prone implications (particularly if I > start with the postulate that everyone thinks like a C programmer). My point above has nothing to do with C or C programmers. - Bob