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

meaning of local define

    Date: Mon, 31 Mar 86 10:34 EST
    From: Guy Steele <gls at THINK-AQUINAS.ARPA>

    Am I confused!  I don't understand why good style allows global DEFINE
    to be used to define things other than procedures, but not local DEFINE.
    It seems to me that in general one ought to be able to use the same
    construct in the same way no matter where it appears.  Call this
    principle "stylistic transparency".  Am I confused?

I agree with this... I guess this is why I thought it might be better to
allow define's to be interspersed with other expressions in
lambda-bodies, and saying they're evaluated sequentially, for uniformity
with "top level".

    As another example of this, one of the things currently distressing some
    users of Common Lisp is that

    (let ((seed (get-universal-time)))
      (defun random (n)
        (setq seed (random-mungicate seed))
        (random-result seed n)))

    doesn't compile properly in all Common Lisp implementations because of
    ad hoc restrictions on where DEFUN is recognized.

In spite of the wishes of many, we're not able at this point to change
define's from being local to being global (like in T, Common Lisp, and
some others dialects, I think), which would be one way to get rid of ad
hoc restrictions.  Another fix would be to allow local define's to
appear anywhere, like in some versions of MIT Scheme, but this is hard
to implement well and at least as confusing as restricting the contexts
in which they're available.  So I think we're stuck with the context

It's implicit in the RRRS that definitions aren't expressions, and I'm
changing the prose for the R^3RS (?) to make this even clearer; see also
the BNF I sent out.  I admit this is more complex, and arguably ad hoc,
but I am hoping that changing the report to emphasize that define's
aren't expressions will help make them seem not ad hoc; the restrictions
will be up front.