Re: Interactive `setq', redux
- From: Madhu <enometh@xxxxxxxx>
- Date: Mon, 16 Jul 2007 17:53:38 +0530
[Ah its been more than a month since this was last discussed on CLL!
I see this thread: <joswig-3A9400.21413106062007@xxxxxxxxxxxxxxxxxxxxxxxx>
( joswig-3A9400.21413106062007 ! news-europe.giganews.com ) ]
* Scott Burson <1184567974.085758.68170@xxxxxxxxxxxxxxx> :
| I want to express my dismay at this turn of events. It's simply
| ridiculous, IMO, that one can't use `setq' in this way. None of the
| `def-' forms (`defvar', `defparameter', etc.) is an adequate
| replacement, either, because:
[...]
| I also can't believe that it was the considered intent of the ANSI
| committee to render `setq' unusable for this purpose. This usage was
| routine on the Lisp Machines and in Allegro at the time the standard
| was being finalized. It's only quite recently that this issue has
| emerged.
|
| () The appropriate primitive for interactive setting of new variables
| is `setq'.
Yes
| () When evaluating such a `setq' form, an implementation should not
| declare the variable globally special.
Only if *TOP-LEVEL-AUTO-DECLARE* is non-NIL.
The rationale for proposing this behaviour rather than what you said is
that there is no mention in the standard of top level lexical variables.
Therefore it is an acceptable worldview that setting a symbol value
would make a variable special, unless explicitly documented otherwise.
| () When evaluating such a `setq' form, an implementation should not
| emit more than one line of warning to the effect that the variable is
| unknown.
If *TOP-LEVEL-AUTO-DECLARE* is NIL, emit one line of warning when
evaluating the SETQ form, and one line of warning when using the
variable.
In interpreted use, there should, in general be no "unknown variable"
warnings, but if a form is compiled the semantics of your variable are
not clear: You can't take symbol-values of lexical variables. Variables
either are lexical or special. This variable is not declared special.
(With the ANSI spec, the compiler can go legally mad.) But the compiler
will have to put out code that looks up symbol-value. So an "unknown
variable" warning would be in order?
If *TOP-LEVEL-AUTO-DECLARE* is [not NIL but] :WARN, print a single
warning, but declare the variable special, along the lines of: "Warning:
Declaring $A special"
*TOP-LEVEL-AUTODECLARE* is CMUCL specific, It is documented. I can
understand it's behaviour, and set the value in my INIT file to suit my
preference. I find this an acceptable thing to do, and the mechanism
provided by CMUCL to be sound and sensible.
However *TOP-LEVEL-AUTODECLARE* comes up for periodic bashing with
complaints about "unintuitive behaviour" and "surprises".
The debate seems to center around the "newbie experience". This being
based on assumptions on a new user *might have*, makes it more of a
political debate. And I suspect that only reason for taking up such a
debate is that championing the cause and winning *might imply* that the
newbie population that have been convinced that they want some behaviour
and now have it, are now your followers, by some weird social logic.
| I understand that we can't claim to annotate the ANSI standard; we've
| just been over that. All I'm asking for is your opinion. (Surely no
| one here will mind providing that :) Do you agree that it would be a
| good thing if implementations followed the above guidelines? If not,
| why not?
There you have my opinion :)
My vote is for the *TOP-LEVEL-AUTODECLARE* mechanism which can be set in
an init file, available in all lisps.
--
Madhu
.
- Follow-Ups:
- Re: Interactive `setq', redux
- From: Scott Burson
- Re: Interactive `setq', redux
- References:
- Interactive `setq', redux
- From: Scott Burson
- Interactive `setq', redux
- Prev by Date: Re: writing my own version of loop
- Next by Date: Re: New Computer Language Shootout?
- Previous by thread: Re: Interactive `setq', redux
- Next by thread: Re: Interactive `setq', redux
- Index(es):
Relevant Pages
|