From: ···@sef-pmax.slisp.cs.cmu.edu
Subject: Re: incrementing w/out setf
Date: 
Message-ID: <C2r3pt.61D.1@cs.cmu.edu>
    My prof. has mentioned that if you're writing good code, you really 
    shouldn't be using 'setf' or at least sparingly.  
    
It's unclear to me what your professor means by "good" code, but I think he
or she is wrong about this in any case.  SETF is often unavoidable, should
(in any decent compiler) compile to code that is as efficient as any other
way of doing the job, and is usually a perfectly clear way of expressing
the programmer's intent.  You may take a performance hit in speed when
running interpreted, but interpreted code is pretty much a loss in most
Common Lisp implementations.  There is difference of opinion in the
community about whether SETF or SETQ is preferable in setting simple
variables.

For incrementing, the programmer's intent is probably expressed more
clearly by using the more specialized INCF form.
    
-- Scott

===========================================================================
Scott E. Fahlman			Internet:  ····@cs.cmu.edu
Senior Research Scientist		Phone:     412 268-2575
School of Computer Science              Fax:       412 681-5739
Carnegie Mellon University		Latitude:  40:26:33 N
5000 Forbes Avenue			Longitude: 79:56:48 W
Pittsburgh, PA 15213
===========================================================================
From: David &
Subject: Re: incrementing w/out setf
Date: 
Message-ID: <1993Feb26.155532.16720@ils.nwu.edu>
···@sef-pmax.slisp.cs.cmu.edu wrote:

:     My prof. has mentioned that if you're writing good code, you really 
:     shouldn't be using 'setf' or at least sparingly.  
:     
: It's unclear to me what your professor means by "good" code, but I think he
: or she is wrong about this in any case.

I think that the professor should be given the benefit of the doubt
here -- especially as we are getting his/her words second hand from a
student.

Clearly in production code one needs to use setf.  However in simple
recursive functions setf can be avoided.  Beginning students often
overlook the use of the stack as a location for information and
instead use an auxiliary variable to hold or pass information.  The
early Lisp assignments try to break the student from the C/Pascal way
of doing things.  Students are often told when assigned recursive
functions to think functionally and so to avoid use of assignment
statements.

--
·····@ils.nwu.edu
Institute for the Learning Sciences, 1890 Maple, Evanston Il 60201