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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a00006d3c4735d70 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-02-26 21:33:38 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!usenet-fr.net!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: In-Out Parameters for functions Date: 27 Feb 2004 00:31:37 -0500 Organization: Cuivre, Argent, Or Message-ID: References: <4020C947.81A6D703@0.0> <1075907239.138068@master.nyc.kbcfp.com> <402232E9.3EE15B4B@0.0> <1075987360.225622@master.nyc.kbcfp.com> <40236C0B.E988E003@0.0> <1077634311.254581@master.nyc.kbcfp.com> <1077718871.47635@master.nyc.kbcfp.com> <54cp3095jmv8s17h63d4bjdus0tec7l7pt@jellix.jlfencey.com> <1077721343.481619@master.nyc.kbcfp.com> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: melchior.cuivre.fr.eu.org 1077859914 37850 212.85.156.195 (27 Feb 2004 05:31:54 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Fri, 27 Feb 2004 05:31:54 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: In-Reply-To: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 X-Virus-Scanned: by amavisd-new-20030616-p7 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:5881 Date: 2004-02-27T00:31:37-05:00 "Robert I. Eachus" writes: > Hyman Rosen wrote: > > > But Ada does not have that philosophy, so that cannot be the reason > > to maintain the feature. When "+" is a user-defined subprogram, its > > operands are always passed in the order written; a + b is always > > invoked as "+"(a, b) and never as "+"(b, a). > > Absolutely wrong. That's an odd thing to say! > If I or any other Ada programmer defines an abstract type Foo, and > it makes sense to add Integers to Foo, and the semantics of addition > are commutative, I will declare: > > function "+"(L: Foo; R: Integer) return Foo is... Let's call this function 1. > function "+"(L: Integer; R: Foo) return Foo is begin return R+L; end > "+"; and function 2. Yes. and the reason you need to do this is that the Ada _language_ requires that 'a + b' _always_ be equivalent to "+" (a, b), not "+" (b, a), as Hymen said! To be more concrete: declare a : Foo; b : Integer; c : integer; d : integer; begin c := a + b; -- calls function 1 d := b + a; -- calls function 2 end; If Ada were allowed to use "+" (b, a) for 'a + b', you would not need function 2 to compute d. -- -- Stephe