Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site nbires.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!hao!nbires!rcd From: rcd@nbires.UUCP (Dick Dunn) Newsgroups: net.lang.mod2 Subject: Re: structured function values Message-ID: <127@nbires.UUCP> Date: Tue, 15-Oct-85 02:09:38 EDT Article-I.D.: nbires.127 Posted: Tue Oct 15 02:09:38 1985 Date-Received: Sat, 19-Oct-85 03:55:56 EDT References: <53@noscvax.UUCP> Distribution: net Organization: NBI,Inc, Boulder CO Lines: 40 >... Modula-2's restriction of function procedure results to be of > unstructured types seems to have no solid justification... Agree. >... Function calls are usually implemented with values returned in the > machine's fast registers, providing they fit in that much space... The "...providing..." here is an important point: As long as it's necessary to make provision, in some architectures, for returning results somewhere other than a register, 1. There's no justification for excluding those processors from the language, nor introducing a processor dependency on the result type of a function, hence 2. "Returnable in a register" is not a reasonable argument for the restriction on result type. >... Allowing structured function values will not introduce strange notations > like func(arg).field or func(arg)[sub] because the components of a structure > are accessed with the syntax: "designator=qualident{selector}", and a function > call is not a qualident. However, Modula allows at present, as far as I can > see, such curiosities as "ffunc(arg)(arg)" if ffunc is a function returning > a function, or funcarray[sub](arg) for arrays of functions. Not allowed at > present is pointerfunc(arg)^... There's no particular reason to disallow the new constructs once a function can return a value of a type which makes them reasonable. The restriction against pointerfunc(...)^ also existed in Pascal. I have never understood why it should exist; in fact, we removed this restriction in a Pascal-based language I worked on some years ago. (That same language also allowed functions to return structured results, with no particular problems.) The overall effect on the language, if anything, is to make it more uniform. > I have never written a compiler myself, so I invite correction if my > suggestion would create unacceptable difficulties... Again, talking about the Pascal-based language that I worked on, my notes say that it added about 150 lines to the compiler (which was a variant of the ETH compiler). That's small change. -- Dick Dunn {hao,ucbvax,allegra}!nbires!rcd (303)444-5710 x3086 ...Simpler is better.