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

Re: Question with binding



$From: Andre van Meulebrouck <vanMeule@allegheny.scrc.symbolics.com>
$    From: titan!dorai@rice.edu  (Dorai Sitaram)
$    I agree with Andre that redefinition of system-defined functions could
$    infringe upon the integrity of the system. In the old Chez, one needed
$    to just type (set! cons 0) to have the whole session come tumbling
$    down like a house of cards. But then, I don't think the guy who said
$    "Eternal vigilance is the price of liberty" meant it as an argument
$    _against_ liberty.
$
$Okay.  All the zeal and arguments shown for allowing the redefinition of car to
$garbage sound pretty good.  And, I'm NOT religious or dogmatic about not
$allowing redefinition.  (In fact, I'm religious about NOT being religious.)   I
$just enjoyed the feature in MacScheme because of all those sleepless nights that
$it saved me from lots of potential inadvertent mistakes that could have made
$already sleepless nights more sleepless.
$
$Recall also, that MacScheme is a "micro" computer implementation.  Perhaps what
$might be nice for "PC"s might not be universally acceptable for "large scale"
$systems.
$
$I just have one question for anyone that's in favor of redefinition.
$
$Are you saying you want redefinition-with-wild-abandon?  I.e. do you NOT want
$the system to warn you and ask you: "Are you sure?"?  (Admittedly there could be
$a hackerish thrill in living dangerously....safety is wimps. :-)
$
$Or, do you want the system to ask you?  (Which could be annoying, especially for
$loading files.)
$
$Or, do you want the system to warn you by default, unless you set a
$global-dont-warn-me-about-redefinitions flag appropriately?  (And if the latter,
$are you prepared to have zillions of such global variables for similar things in
$a BIG MOBY system?)
$
$Just curious (And by NO means intending raging controvery and/or heated
$religious debates.  If I'm espousing unpopular ideas, well, I derived them from
$reading Salmon Rushdie--so he's to blame!)
$
$<Happy trails>  =:0)

Your concerns are perfectly legitimate: inadvertent or misguided
redefinition can cause no end of trouble. However, an irreversible
abolition of redefinition is not only aesthetically unpleasing to
those with "hackerish thrills", it is _unnecessary_. "Redefinition
with wild abandon" is not an untam(e)able animal at all. The system
warnings you ask about are also unnecessary. Even for small pc
implementations. Why?

The reason is that you can devise your own security blanket (and sleep
tight ;-}) with the macro system that comes with any Scheme. The
declare-constant and undeclare-constant that I referred to in my
earlier posting are now simple macros. One method would be:

(defmacro (declare-constant x)
  `(put 'x 'constant t))

(defmacro (undeclare-constant x)
  `(put 'x 'constant nil))

(defmacro (setq x v)
  `(if (get 'x 'constant)
       (error "hey watch out, salman rushdie is out to set constants!")
       (set! x ,v)))

The above is a very simple model (it hardly deserves the term
"hack"!). You can of course make it more watertight by avoiding use of
a global property table (make it local to the un/declare-constant and
setq macros). The use of setq as the new set! can also be avoided, by
lexically capturing the old set! (macro-)transform-function and
replacing it with the modified version.  All these are peripheral to
understanding how to get a very satisfactory method of getting safe
"constant" names in a system that provides redefinition.

Anyway, the upshot of all this is that redefinition allows one to get
the best of both worlds, while condemning the system to have immutable
"constants" is an irreversible situation. Which would you choose? :-]

--dorai
------------------------------------------------------------------------------
We must believe in free will. We have no choice.       --Isaac Bashevis Singer
------------------------------------------------------------------------------