[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How's that again?

    From: "Mark A. Tapia" <markt@dgp.toronto.edu>
    To: hall@research.att.com
    The first error is correct since the variable x is declared in the 
    dolist form but not used. The second error is also correct since the
    variable x is used for the "dolist" iteration but not in the body.

On the face of it, a variable is either ignored or not.  I see your point,
but I believe the first error message should have said something like
"variable x is written but not read" or the like.

    The following removes the error message:
    ? (defun foo (l)
	(dolist (x l)
	  (declare (ignorable x))
	  (print "Hi")))

Thanks.  Is "IGNORABLE" as portable as "IGNORE"?  What about IGNORE-IF-UNUSED?
(see below).  My code has to compile in three different common lisps.
(MCL, Franz, Harlequin).  

    Some stylistic remarks are in order.

    Unless you intend to reference x in the body of the dolist form, you
    should use dotimes or loop.

Right.  My example is abstracted from a much bigger application.
Currently, not all the features are implemented in that application,
so the dolist subforms that use x are commented out.  Nevertheless,
I'd like the code to compile silently as is, because I want to give
out early versions for testing.  Maybe I should just break down and recode the
loop as you suggest below until the new features are implemented.
    Also, please choose variable names that mean something. For example,
    use "list"  instead of "l" and "el" (or "element") instead of "x".

Yes, of course.  I was merely abstracting for the purposes of this email.
I didn't think having the original variable name would add anything
to my message's point: (DOLIST (EVENT-HANDLER <big expr>)...) 

Thanks for the response.

    Date: Tue, 1 Feb 1994 09:58:15 -0500
    From: e@Flavors.COM (Doug Currie, Flavors Technology, Inc.)
    Translation: UnREAD lexical variable X, in FOO.

I would think this is a more informative error message than what they
currently give.

    ? (defun foo (l)
	(dolist (x l)
	  (declare (ignore-if-unused x))
	  (print "Hi")))


Thanks for the response.

-- Bob