From: Darren New <dnew@san.rr.com>
Subject: Re: Out parameters in a function
Date: Wed, 17 Apr 2002 16:32:17 GMT
Date: 2002-04-17T16:32:17+00:00 [thread overview]
Message-ID: <3CBDA3D7.7F2CC728@san.rr.com> (raw)
In-Reply-To: ug01ufofm.fsf@gsfc.nasa.gov
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%.
next prev parent reply other threads:[~2002-04-17 16:32 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-14 18:29 Out parameters in a function Nazgul
2002-04-14 19:45 ` David C. Hoos, Sr.
2002-04-15 10:49 ` John McCabe
2002-04-15 11:51 ` John McCabe
2002-04-15 13:43 ` Steve Doiel
2002-04-15 15:09 ` Ted Dennison
2002-04-16 8:49 ` John McCabe
2002-04-16 10:05 ` Dmitry A. Kazakov
2002-04-16 15:26 ` John McCabe
2002-04-16 19:34 ` Matthew Woodcraft
2002-04-16 20:10 ` Darren New
2002-04-17 1:30 ` Kent Paul Dolan
2002-04-17 16:15 ` Darren New
2002-04-19 17:39 ` Florian Weimer
2002-04-17 13:24 ` Stephen Leake
2002-04-17 16:32 ` Darren New [this message]
2002-04-17 21:03 ` Kent Paul Dolan
2002-04-18 12:14 ` Wolfgang Gellerich
2002-04-18 13:52 ` Dmitry A. Kazakov
2002-04-18 16:28 ` Darren New
2002-04-17 10:17 ` John McCabe
2002-04-16 19:58 ` Kent Paul Dolan
2002-04-16 20:00 ` Kent Paul Dolan
2002-04-17 4:40 ` Jim Rogers
2002-04-17 5:27 ` Kent Paul Dolan
2002-04-17 5:50 ` Eric G. Miller
2002-04-24 2:45 ` David Thompson
2002-04-19 17:40 ` Florian Weimer
2002-04-19 18:26 ` Jim Rogers
2002-04-19 18:53 ` Florian Weimer
2002-04-17 7:57 ` Dmitry A. Kazakov
2002-04-17 10:21 ` John McCabe
2002-04-24 17:21 ` Warren W. Gay VE3WWG
2002-04-26 7:32 ` Dmitry A. Kazakov
2002-04-15 16:24 ` Stephen Leake
2002-04-16 13:38 ` Ted Dennison
2002-04-17 11:55 ` Ingo Marks
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox