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-Thread: 103376,b8b8a54001adc4d2 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Possible Ada deficiency? Date: 09 Jan 2005 12:30:40 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1104516913.718856.94090@z14g2000cwz.googlegroups.com> <1104544963.930877.75170@c13g2000cwb.googlegroups.com> <1104595073.731663.180100@c13g2000cwb.googlegroups.com> <2J1Ed.1997$Ii4.1084@newsread3.news.pas.earthlink.net> NNTP-Posting-Host: shell01-e.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1105291840 18860 69.38.147.31 (9 Jan 2005 17:30:40 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 9 Jan 2005 17:30:40 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:7582 Date: 2005-01-09T12:30:40-05:00 List-Id: Jeffrey Carter writes: > Robert A Duff wrote: > > > Jeffrey Carter writes: > > > >>All such types would, of course, be passed by reference. > > Well, that would require changing the current rules, > > which require pass-by-copy for a private type if the > > full type is elementary. (I don't much like the existing rules > > in this area, but I'm not sure the change suggested here would > > be an improvement. It would be seriously incompatible, for > > one thing.) > > It's not going to happen in Ada anyway, ... True. I guess I shouldn't use upward compatibility in an argument about pie-in-the-sky language design. >...and if you designed a language > to work this way, you wouldn't have such rules in the 1st place. What rule would you prefer (in a from-scratch language design)? The main thing I dislike about the Ada rule is that it is possible to write code by accident that behaves differently because one compiler chooses pass-by-copy and another one pass-by-reference. And it's not clear whose responsibility it is to worry about this kind of bug: should procedures be written so that they work even in the presence of aliasing among actual parameters? Or should callers avoid that aliasing? And what can the caller know about data modified in a procedure that raised an exception in the middle of processing? I also think it's kludgy to treat (say) integers differently from strings. I understand the efficiency reason for this, but I still don't like it. I can think of several solutions, but I'm not sure which is best. One idea is to define all parameter passing to be nominally by copy, but add some features that allow the compiler to know enough about global variables and whatnot, so that it can use by-reference in most cases, having proved it doesn't make any difference. That wouldn't work in Ada because the compiler doesn't have enough information to do the proof, in most cases. - Bob