From: Hallvard Tretteberg
Subject: let vs. multiple-value-bind
Date: 
Message-ID: <HAL.93Jan17132104@monsun.si.no>
Hi, I'm considering a new coding style and since one of the main
purpose of any style should be to help the reader of code, I thought
I'd ask you what you think of it.

I'm working on code for graphics and find I often write let forms
like:

(let ((x (node-x node))
      (y (node-y node)))
  ...) 

To show that the x and y are considered a pair I thought the following
would be easier to read:

(multiple-value-bind (x y) (values (node-x node) (node-y node))
  ...)

I guess I would also make a function (node-xy-values node) to return
the two values.

Which do you like best, the let or the multiple-value-bind as they are
written above (i.e. without the use of node-xy-values).

Since I'm also interested in Lisp internals, is there any performance
penalty whatsoever in using multiple-value-bind instead of let?

Hallvard
--
Hallvard Traetteberg
Dept. of Knowledge Based Systems
SINTEF SI (Center for Industrial Research)
Box 124 Blindern, 0314 Oslo 3
NORWAY

Tlf: +47 2 45 29 83 or  +47 2 45 20 10
Fax: +47 2 45 20 40
Email: ···················@si.sintef.no

From: Eyvind Ness
Subject: Re: let vs. multiple-value-bind
Date: 
Message-ID: <1993Jan18.083706.2374@dhhalden.no>
In article <·················@monsun.si.no>, ···@si.no (Hallvard Tretteberg) writes:
 | 
 | I'm working on code for graphics and find I often write let forms
 | like:
 | 
 | (let ((x (node-x node))
 |       (y (node-y node)))
 |   ...) 
 | 
 | To show that the x and y are considered a pair I thought the following
 | would be easier to read:
 | 
 | (multiple-value-bind (x y) (values (node-x node) (node-y node))
 |   ...)
 | 
 | Which do you like best, the let or the multiple-value-bind as they are
 | written above (i.e. without the use of node-xy-values).

I think I prefer the LET cliche. I guess I can't give you a *good*
explanation of why I do, though. LET just looks better in my eyes :-)
With LET I can immediately tell what you're up do, but with the
MULTIPLE-VALUE-BIND I'd have to spend a little extra mental energy to
figure out what it is you're trying to do. Also, it appears that LET
comes out better when consulting your own Style Guide: "Always use the
most specific construct". Assuming, of course, that LET is more
specific than MULTIPLE-VALUE-BIND is this connection.

 | Since I'm also interested in Lisp internals, is there any performance
 | penalty whatsoever in using multiple-value-bind instead of let?

That might very well be the case. Try a couple of MACROEXPAND-1's in
your favorite CL to find out.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
  Eyvind Ness         Internet: ···········@HRP.No
  Research Scientist  Voicenet: +47 9 183100 ext. 275
  CRS Division        Faxnet:   +47 9 187109
  OECD HRP            Papernet: PO Box 173, N-1751 Halden, Norway

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
From: Mark Kantrowitz
Subject: Re: let vs. multiple-value-bind
Date: 
Message-ID: <C12AtH.5qH.1@cs.cmu.edu>
As I remarked to Hal in email, the "new" CLOS macro WITH-SLOTS should do
what he wants. 

--mark