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,f3437064e1091fec X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-11 21:30:11 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!82-43-33-75.cable.ubr01.croy.blueyonder.co.UK!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: What evil would happen? Date: Sat, 12 Jul 2003 05:31:45 +0100 Message-ID: References: <5ad0dd8a.0307111151.4a08f95a@posting.google.com> <1LEPa.9034$nP.7178@newsfep4-winn.server.ntli.net> NNTP-Posting-Host: 82-43-33-75.cable.ubr01.croy.blueyonder.co.uk (82.43.33.75) X-Trace: news.uni-berlin.de 1057984210 7777349 82.43.33.75 (16 [25716]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Xref: archiver1.google.com comp.lang.ada:40221 Date: 2003-07-12T05:31:45+01:00 List-Id: "chris.danx" wrote in message news:1LEPa.9034$nP.7178@newsfep4-winn.server.ntli.net... > Wojtek Narczynski wrote: > > Hello, > > > > What would happen if a procedure could return a value > > like a function, > > Surely, it would be a function? I think the idea is that the result returned by the procedure is written into an implicit variable with a conventional name. Suppose the name is 'Result', then you might have something such as: procedure P(...) is begin ... return X*25.4; end; and then: P(...); if Result > 200.0 then ... Some languages which are typeless (and/or fully polymorphic) have this kind of facility. Nearly all assembly languages essentially work this way (think of registers). I think it is clear how badly suited it is to a strongly typed language such as Ada. Obviously you could simulate the effect by simply writing into a global variable, e.g.: Result: Float; procedure P(...) is begin ... Result := X*25.4; end; but this is not considered good programming style. A situation in which it might make sense for Ada to permit a return statement with an expression in a procedure body is for a procedure which will be called from a foreign language (and so to which pragma Export applies). The call in the foreign language may look like a procedure call, but the language may require a value to be invisibly returned by the procedure (e.g. indicating success or some kind of failure). Regarding the parameter modes of functions, I think the main Ada Issue to refer to is AI-323. -- Nick Roberts Jabber: debater@charente.de [ICQ: 159718630]