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,9245b8db9abd376c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-17 09:33:15 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed1.cidera.com!Cidera!cyclone.columbus.rr.com!cyclone3.kc.rr.com!news3.kc.rr.com!twister.socal.rr.com.POSTED!not-for-mail Message-ID: <3CBDA3D7.7F2CC728@san.rr.com> From: Darren New X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Out parameters in a function References: <3cbbe583.3628858@news.demon.co.uk> <3cbc3f05.26543327@news.demon.co.uk> <3CBC855D.148232E3@san.rr.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 17 Apr 2002 16:32:17 GMT NNTP-Posting-Host: 66.75.151.160 X-Complaints-To: abuse@rr.com X-Trace: twister.socal.rr.com 1019061137 66.75.151.160 (Wed, 17 Apr 2002 09:32:17 PDT) NNTP-Posting-Date: Wed, 17 Apr 2002 09:32:17 PDT Organization: RoadRunner - West Xref: archiver1.google.com comp.lang.ada:22663 Date: 2002-04-17T16:32:17+00:00 List-Id: Stephen Leake wrote: > What is the difference between an "anonymous tuple" and "multiple > values"? That's how I would _define_ "anonymous tuple"! Typing, how you access them, etc. It's quite reasonable to postulate a FORTH word that returns multiple values which could not all be assigned to the same variable. In addition, consider "ROT3". What does that "return"? :-) (And of course there's assembler, where you can do things like "if AX==1, then HL points to the string return value, else DE contains an integer...") > In Forth, I can push several values on the stack, and then return > from the word (it's _not_ a "function", it's a "word" :). I've written FORTH interpreters. But I'm posting in an Ada newsgroup. :-) > In Ada, I > can set several values in the return type, and then return. I don't > see that the difference is significant. The syntax is different, but > not the semantics. One (minor) difference is that I can (for example) decide to return a value or not, or return a boolean saying whether or not the other return value is a file descriptor or a string, or whether I returned a second value at all, or etc. I can also "return" values at various places in the code without actually returning execution control at the same point. I haven't thought it thru, but the fact that I can return 4 values, and use 2 in the next call and 1 in the call after that and leave one as the return might count as well. (All without assigning anything anywhere, of course.) > Hmm. In Forth I can decide at run time how many values to push on the > stack. I can do that in Ada with an unconstrained array; not quite as > flexible, but way safer :). Of course returning multiple values vs returning a single value with multiple components is pretty close, so getting all nitpicky over it is kind of silly. Just like you *could* program something like Ada without functions, turning functions into procedures with an out parameter and just declaring a lot of excess variables. (Modulo needing functions to create values for unconstrained types, etc etc.) Kind of like arguing that Fortran has I/O built in, while C doesn't, because in C it's just standard libraries rather than language statements. A minor and mostly-irrelevant point. I'm just saying that I expect if you look at the definition of a language like occaml, you'll see that technically functions return a single value which may be a tuple, just like in APL a function returns a single value which may be an array. It's just easier, cleaner, and with modern compiler technologies just as efficient, I'd expect. (Not saying FORTH is better, just different.) -- Darren New San Diego, CA, USA (PST). Cryptokeys on demand. The 90/10 rule of toothpaste: the last 10% of the tube lasts as long as the first 90%.