[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reviving an old discussion about IGNORE
Subject: Reviving an old discussion about IGNORE
To: MILLER
From: Siskind.pa@Xerox.COM
To: slug@Warbucks.AI.SRI.COM
cc: Qobi@AI.MIT.EDU
Message-ID: <19890915170852.9.SISKIND@PORTNOY.parc.xerox.com>
Character-Type-Mappings: (1 0 (NIL 0) (NIL :BOLD NIL) "CPTFONTCB") (2 0
(NIL 0) (NIL :ITALIC NIL) "CPTFONTI")
Fonts: CPTFONT, CPTFONTCB, CPTFONTI
Line-fold: no
Most Lisp compilers a sociable and give a warning when
a lexical variable is not used. CommonLisp provides an
IGNORE declaration to keep the compiler quiet in such
instances. In Genera, there are four ways of accomplishing
this task, only one of which is supported by CommonLisp.
... <four methods to ingore unused variables> ...
The ivory does not produce redundant code for either
(defun FOO (x y)
(ignore y)
(bar x))
or
(defun FOO (x y)
y ;ignore
(bar x))
What's the point of this all? There are two problems with all of
this.
First of all I want to write something like:
(loop for x in l collect t)
This is a simple way of creating a list of t's which is the same
length as l. I know there are other ways but I think that this
way generates the most efficient code.
What's wrong with (make-list (length l) :initial-element T) ?
It is surely the most readable. It even gives a cdr-coded list
on a Symbolics, which is good unless you want to rplacd.
... <observations & speculations how to work around it>...
LOOP has always been a bit peculiar. I had forgotten that args named IGNORE was
not common lisp, but even so it always seemed odd (and somehow illegitimate) that
you used NIL for arguments or pattern elements in LOOP that you wanted to ignore.
The fragment below works on 36xx & Ivory
(loop for nil in l
collect t)
but I dont know about other common lisps. Also note that LOOP is not yet
(or is it now?) part of common lisp and so you might be using a general purpose
heavily conditionalized macro; who knows what it expands into?
The second problem is that often I write macros to set up lexical
environments for forms. For example:
(defmacro WITH-MY-LEXICAL-VARIABLES (&body body)
`(let ((x (foo))
(y (bar)))
,@body))
...< Note that x & y may or may not be used; How do you declare it?> ...
What do I do?
Jeff
-------
This one DOES bother me because I am quite fond of this style of macro.
I'll go you one better:
(defmacro WITH-MY-LEXICAL-FUNCTIONS ((argstuff) &body body)
`(flet ((dothis () ,(foo argstuff))
(dothat () ,(bar argstuff)))
<Now tell the compiler that dothis & dothat may or maynot be called!>
,@body))
[or maybe with macrolet ]
Maybe you think this is perverse, but it can make for code that
is at the same time readable and nicely tuned.