Xref: utzoo comp.lang.misc:2267 comp.arch:7430 Path: utzoo!utgpu!watmath!clyde!att!pacbell!ames!sgi!arisia!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.misc,comp.arch Subject: Re: Assembly or .... Message-ID: <794@quintus.UUCP> Date: 2 Dec 88 08:34:25 GMT References: <1388@aucs.UUCP> <729@convex.UUCP> <1961@crete.cs.glasgow.ac.uk> <2416@osiris.UUCP> <1037@l.cc.purdue.edu> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 53 In article <1037@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: >> In article <1032@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes: >> >A trivial example [of useful operations unsupported in HLLs] is having a >> >list of results to the left of the replacement operator. I do not mean a >> >vector or a struct; the items may be of different types, and should not be >> >stored in adjacent memory locations. >Besides the quotient and remainder, there are operations like unpacking >floating point numbers into exponent and mantissa, which are hardware on >some machines, and should be on others. The problem of functions returning a single result has long been a thorn in the side of Lisp programmers (who didn't have VAR parameters either). The Lisp community finally fixed this. See "multiple-" in the index of "Common Lisp the Language". As a specific example of this: (multiple-value-setq (Significand Exponent Sign) (decode-float SomeFloatingPointExpression)) [see P218 of CLtL.] The fact that the result variables are in a list has no non-syntactic significance. A Common Lisp implementation can support multiple values any way the implementor pleases (a list or array of results *might* be built, or it might *not*) but no structure is visible to the programmer. (For example, if you just write (decode-float SomeFloatingPointExpression) you will not get a list of results, just the first one.) If the compiler knows how to generate inline code for this particular operation, it is quite at liberty to do so. Prolog does not distinguish in any way between "inputs" and "outputs". If a version of Prolog had this particular operation, it would be decode_float(ANumber, Significand, Exponent, Sign) and you could use this to test for zero the hard way: decode_float(ANumber, 0.0, _, _) All functions in MESA *look* as though they receive a single argument (a record) and return a single result (another record). It's a long time since I read a MESA manual, so I've probably got this wrong, but the function in question would look like function decode_float[x: real] returns [significand: real, exponent: integer, sign: real]; begin ... end; ... [m, e, s] := decode_float[27.3]; Although the syntax of a record is used, this has no more significance than the list of variables in Common Lisp. The implementation *might* construct a record, or it might not. (VAR parameters might be used instead.) I don't understand why ADA didn't pick this up from MESA. The fact that procedures and record constructors both support keyword association is automatic in MESA, but requires separate statement in ADA. And MESA multiple results also support keyword association.