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,8522260ffbf09d84 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-05 05:31:16 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Problem With Self-Referential Access-to-Subprogram Type Date: Wed, 05 Nov 2003 14:33:12 +0100 Message-ID: References: <80teqv099lspc5d4osf2gmu7cld46i0lvb@4ax.com> <20chqvglnrae8njr0011cfg3a8hc82je7m@4ax.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1068039075 43371842 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:2078 Date: 2003-11-05T14:33:12+01:00 List-Id: On Wed, 05 Nov 2003 11:27:22 +0000, Marius Amado Alves wrote: >On Wed, 2003-11-05 at 08:31, Dmitry A.Kazakov wrote: >> >> Yes, there is a difference. Technically, for an out parameter the >> >> compiler should still know the object constraints. > >> >Only at runtime. Consider Ada.Text_IO.Get (Item : out String). What >> >constraints is the compiler knowing here? > >> It knows that there are bounds which cannot be changed. If Item were >> of String (1..5) the compiler would probably choose another way of >> parameter passing than for String (<>) with the consequence that the >> stack frame would be different. > >Irrelevant. This applies to return types just as well. They are "bad" anyway. A return value is potentially a newly allocated object. An out parameter is not (copy out does not count). So a difference does exist. BTW, there is an AI for returning / initializing limited type objects. Let's see (:-)) >The original poster has a very good question--which has found no real >answer yet. My guess is it comes down to the hardware-orientedness of >Ada. C++ is also hardware-oriented, but solves this other way, which I do not like much. Returning to Ada let's compare: type Mysterious; function Create return Mysterious; Init : constant Mysterious; -- Illegal procedure Baz (X : Mysterious := Init); -- Illegal procedure Bar (X : Mysterious := 0); -- Illegal, Ada is not C++! procedure Foo (X : Mysterious := Create); -- Illegal ... type Mysterious is new Integer; Init : constant Mysterious := 0; with type Mysterious is private; function Create return Mysterious; Init : constant Mysterious; procedure Bar (X : Mysterious := Create); procedure Bar (X : Mysterious := 0); -- Still illegal procedure Foo (X : Mysterious := Init); ... private type Mysterious is new Integer; Init : constant Mysterious := 0; Private types are much more prematurely usable! (:-)) BTW there is a more serious problem than premature use. That is an inability to hide the parameter defaults of a subroutine if the type has to be private. You have to expose Init and Create, even if their direct use is undesirable. > I was surprised the *first* form compiled. Well, now the language lawyers have to say ... (:-)) --- Regards, Dmitry Kazakov www.dmitry-kazakov.de