[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
New issue: FLET-DECLARATIONS
- To: Cl-Cleanup@SAIL.STANFORD.EDU
- Subject: New issue: FLET-DECLARATIONS
- From: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>
- Date: Fri, 1 Jan 88 15:45 EST
- Cc: Hornig@STONY-BROOK.SCRC.Symbolics.COM
This comes from Steele's 1985 list. I thought that the Cleanup
committee had picked this one up long ago, but in looking over the
status list it seems like it's never been written up. Perhaps it's too
non-controversial? I think we may have discussed this at a face to face
meeting last year and decided we were afraid of anything that touches
upon declaration scoping. However, I think there is only one possible
declaration scoping rule for these that is consistent with CLtL.
References: FLET, LABELS, MACROLET (CLtL p.113)
X3J13 document 86-003 item 113
Edit history: Version 1, Moon, 1 Jan 1988
Declarations are not allowed before the body of FLET, LABELS, and
MACROLET, even though Common Lisp allows declarations in other seemingly
analogous places, such as LET.
Change the syntax of FLET, LABELS, and MACROLET to allow declarations
between the list of local function/macro definitions and the body forms.
In MACROLET, an invocation of one of the macros locally defined by that
MACROLET is permitted to expand into a DECLARE (assuming Common Lisp is
not changed to forbid any macros to expand into DECLARE).
The scope of such declarations in FLET and LABELS includes the bodies
of the locally defined functions, when the declarations are pervasive.
Non-pervasive declarations have no effect on those bodies, except when
LABELS includes the body in the scope of a function non-pervasively
declared. This paragraph follows directly from CLtL p.155 if the
locally defined function bodies are treated like initialization forms.
(This paragraph will be superseded by a proposal on declaration
scoping that Hornig plans to make soon.)
The scope of such declarations does not include the bodies of the
macro expander functions defined by MACROLET. This is consistent with
the existing rule that the bodies of those functions are in the global
environment, not the local lexical environment. This rule is required
in order to permit macros to expand into DECLARE, as noted above.
(defun example (y l)
(flet ((attach (x)
(setq l (append l (list x)))))
(declare (inline attach))
(dolist (x y)
(unless (null (cdr x))
(example '((a apple apricot) (b banana) (c cherry) (d) (e))
'((1) (2) (3) (4 2) (5) (6 3 2)))
=> ((1) (2) (3) (4 2) (5) (6 3 2) (a apple apricot) (b banana) (c cherry))
The above function is erroneous in current Common Lisp. With this
proposal, it would have an intuitively obvious meaning.
This will make the syntax of FLET and LET consistent. This will make
it possible to attach declarations to function bindings; currently only
variable bindings can have attached declarations.
I do not know of any Common Lisp implementations that allow declarations
Cost to Implementors:
The compilation and interpretation of three special forms will have to
be changed, however the same techniques already developed for
declarations in LET should be applicable.
Cost to Users:
No cost since this is an upward-compatible addition.
Cost of non-adoption:
Unnecessary inconsistency in the syntax of Common Lisp.
There is no major benefit but the language will be more consistent.
Makes the language more consistent.
We need to resolve this for CLOS, because CLOS introduces two new
special forms similar to FLET and LABELS and we need to make their