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,782af4edeb84c4b7 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news.glorb.com!solaris.cc.vt.edu!news.vt.edu!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: basic basic ada question Date: Sat, 21 Oct 2006 13:53:30 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1161268231.345231.242170@m73g2000cwd.googlegroups.com> <4537bc65_1@newsfeed.slurp.net> <5567b72ia0c9$.1b6yl0tpfscj5$.dlg@40tude.net> <13bxqw4vydm93$.vlnod0hnsogo.dlg@40tude.net> <2lh16y6eetpr.174c6t4885tws$.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1161453210 4857 192.74.137.71 (21 Oct 2006 17:53:30 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 21 Oct 2006 17:53:30 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:BOwBi20N2LL3EZ5f1waBgOqz+dM= Xref: g2news2.google.com comp.lang.ada:7120 Date: 2006-10-21T13:53:30-04:00 List-Id: "Dmitry A. Kazakov" writes: [lots of good stuff snipped] > On Fri, 20 Oct 2006 16:59:49 -0400, Robert A Duff wrote: >> Return-by-reference was a bad mistake in Ada 95. It's very cool that in >> Ada 2005 you can say: >> >> function F(...) return T; >> >> where T is limited, contains tasks, etc, and F creates a new object of >> type T. > > Though it does not work with assignments. Assignment statements, you mean. (The RM uses the term "assignment" for both assignment_statements and initializations.) Of course not! If assignment statements were allows for limited types, they wouldn't be limited anymore. The whole point of "limited" is to prevent copying (of already-existing objects). The mistake in Ada 83 and Ada 95 was in confusing initialization with assignment_statement. They are rather different things -- initialization starts out with an empty bucket of meaningless bits. > I meant things like Initialize and Finalize. Presently, a derived type is > free to skip them. There obviously should be parts of user-defined > constructors which cannot be circumvented [otherwise than by > Unchecked_Conversion or Program_Error propagation]. Lisp has methods that are called in addition to the parent's method, as well as the more usual methods that replace the parent's method. There was some discussion in the ARG about a feature that would allow you to declare that all overridings must call the parent operation. Probably checked at compile time. I don't think it went anywhere. Initialize and Finalize are not the only operations that have this problem > Not so fine. When an array is returned there is a good chance that it will > be copied. Arrays are no different than records in this regard. Limited arrays are never copied on function return. Nonlimited arrays need not be copied if the function creates a new object to return, and the function is called in an initialization context (as opposed to an assignment statement, which must copy if the function itself can get its hands on the left-hand side). - Bob