dwtill@watyew.waterloo.edu (Dave Till) (07/14/89)
In article <1207@quintus.UUCP> pds@quintus.UUCP (Peter Schachte) writes: >All is not lost, though. In C, you can have > > divrem(top, bottom, "ient, &remainder) > >and something similar is possible with VAR parameters in Pascal (and >Modula-2, I think). This is symmetrical and reasonably elegant. More >elegant, I think, than complicating a language with multiple value >expressions without adding enough power to do anything other than assign >them to something. I think it would be more elegant to allow the returning of multiple values, as in [quotient,remainder] = divrem(top,bottom); because then it would be clear that "quotient" and "remainder" are return values, not input parameters or in-out parameters. Using multiple return values also allows the user to remove unnecessary dereferencing operations from the called function. >Basically, there's not much you can do with a multiple-value expression >except ignore all but the first value (which happens if you nest a MV >expression within a function call) and assign its results to variables. I may have misunderstood what you are saying here, but I disagree: I believe it is possible to use a multi-valued expression as part of a parameter list for a function call. In fact, I believe that a parameter list for a function call *is* a multiple-value expression. I am trying to determine the applications of multiple-value expressions and multiple return values from functions as part of my master's thesis work, and would be happy to discuss this by e-mail with anyone who is interested. (I have written a C preprocessor which implements constructs such as the above, and am trying to figure out how useful these constructs are.) Followups directed to comp.lang.misc, since this isn't really an architecture-related issue any more. -- --Dave Till, Computer Science Department, University of Waterloo (dwtill@watyew.waterloo.edu) ...<known universe>!watmath!watyew!dwtill "Bottle, say after me, I must learn the difference between a lion and a spider." -- Eccles to Bluebottle, the Goon Show, "Ned's Atomic Dustbin"