🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #397

Re: Language Tenets (too long)

#397
From: Mark Meyer
Date: Fri, 04 Aug 1989 22:58
35 lines
2032 bytes
In article <1223@quintus.UUCP> pds@quintus.UUCP (Peter Schachte) writes:
>* CommonLisp has 5 forms for handling multiple returns, but none of them
>allow you to get multiple results from one function call into different
>function calls without putting them into variables first.  For example,
>suppose CommonLisp had a divrem function, and suppose I wanted to
>compute x/y*10+log(x%y).  I don't see how to do this conveniently without
>putting x/y and x%y into temporary variables.  Maybe I'm just missing
>it.

	Perhaps you are.  Either that or I'm missing your point.
Anyway, Common LISP >does< have divrem; it's called truncate.  Given x
and y, (truncate x y) yields two values q and r such that q*y+r=x,
0<=|r|<|x|, and sign(x)=sign(r).
	Now, for computing x/y*10+log(x%y), doesn't
multiple-value-call do what you want?  If we do

		(defun f (q r) (+ (* q 10) (log r)))

then

		(multiple-value-call f (truncate x y))

computes the original expression for us, taking a pair of values from
one function and passing them to another.

>-- 
>-Peter Schachte
>pds@quintus.uucp
>...!sun!quintus!pds

--
Mark Meyer          USENET: {ut-sally!im4u,convex!smu,sun!texsun}!ti-csl!mmeyer
Texas Instruments, Inc.                                   CSNET : mmeyer@TI-CSL
TI's too busy making chips - I had to come up with these opinions myself.
  Any sufficiently advanced technology is indistinguishable from a rigged demo.
Technical Details
Message-ID: <86638@ti-csl.csc.ti.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!bellcore!texbell!attctc!pollux!ti-csl!m2!mmeyer
References: <57125@linus.UUCP> <1989Jun24.230056.27774@utzoo.uucp> <1207@quintus.UUCP> <1406@l.cc.purdue.edu> <1989Jul17.184707.415@maths.nott.ac.uk> <1223@quintus.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!bellcore!texbell!attctc!pollux!ti-csl!m2!mmeyer
From: mmeyer@m2.csc.ti.com (Mark Meyer)
Newsgroups: comp.lang.misc
Subject: Re: Language Tenets (too long)
Message-ID: <86638@ti-csl.csc.ti.com>
Date: 4 Aug 89 22:58:43 GMT
References: <57125@linus.UUCP> <1989Jun24.230056.27774@utzoo.uucp> <1207@quintus.UUCP> <1406@l.cc.purdue.edu> <1989Jul17.184707.415@maths.nott.ac.uk> <1223@quintus.UUCP>
Sender: news@ti-csl.csc.ti.com
Reply-To: mmeyer@m2.UUCP (Mark Meyer)
Organization: TI Computer Science Center, Dallas
Lines: 35