Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!brutus.cs.uiuc.edu!wuarchive!wugate!uunet!philmtl!ray From: ray@philmtl.philips.ca (Raymond Dunn) Newsgroups: comp.lang.misc Subject: Re: Language Tenets Message-ID: <612@philmtl.philips.ca> Date: 21 Jul 89 22:37:11 GMT References: <57125@linus.UUCP> <1989Jun24.230056.27774@utzoo.uucp> <1207@quintus.UUCP> <1406@l.cc.purdue.edu> Reply-To: ray@philmtl.philips.ca (Raymond Dunn) Organization: Philips Electronics Ltd. - St. Laurent P.Q., Canada Lines: 61 I missed the start of this discussion, I hope the following is a relevant contribution. In the POP-2 language and its derivatives, multi-result functions are handled in a very straight forward manner: Assignment in POP-2 is left to right, e.g. 5 -> x; Thus to assign the result of a single result function one can do: foo(x) -> y; To assign the results of a multi-result function then, one does: foo(x) -> y -> z; with no practical limitations on the number of results that can be returned in this way. [someone] wrote: >> There's a big problem with this: you have an expression that's no good >> for anything but putting on the right side of an assignment. What good >> are expressions if you can't nest them? In POP-2 this is not the case, if foo is a function of n arguments and bar is a function of one argument and n results, then: foo(bar(x)); is meaningful. Indeed if foo is a function of *one* argument and bar is a function of two results, then: foo(bar()->x); is "equivalent" to: bar() -> x -> y; foo(y); etc. (I don't hold this up as pretty useage, only as a demonstration of the feature). If you think of "f(x,y)" as "push x, push y, call f", and "-> x" as "pop x", then the underlying [stack] mechanism and its usages should be self evident. The types of arguments and results of functions are also not restricted in any way, a value of any type may be passed and returned (integer, real, array, record [structure], function, list etc). As a POP-2 programmer of old, I *still* find it a pain in 'C' to be forced into creating unnecessary structures (or, god forbid, using global variables) just to be able to return multiple values. -- Ray Dunn. | UUCP: ..!uunet!philmtl!ray Philips Electronics Ltd. | TEL : (514) 744-8200 Ext: 2347 600 Dr Frederik Philips Blvd | FAX : (514) 744-6455 St Laurent. Quebec. H4M 2S9 | TLX : 05-824090