[pro] (values) for for-effect functions

David Owen dsowen at fugue88.ws
Thu Dec 2 23:30:36 UTC 2010


On Thu, 2 Dec 2010, Peter Seibel wrote:

> My taste tells me that's an over-clever idiom and should not be
> used.  If it's not clear that a function is for-effect without
> (values) you've already lost.

I confess that I have used (values) before, not only to indicate that
a function was for effect only, but also to prevent any implementation
detail from leaking out.  I also like m-v-l's behavior when receiving
(values).

(I also confess that I haven't been consistent in this use.)

On the other hand, I agree with Peter that it can be somewhat ugly.
Maybe some alternatives, based on (values)?

(defun f ()
   (for-effect
     (setq *foo* 'bar)))

Or, how about:

(defeffect f ()
   (setq *foo* 'bar))

for-effect and defeffect could have the added benefit of guaranteeing that 
*no* return path will return a value.

-David




More information about the pro mailing list