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

(define foo)



    Date: Sun, 7 Dec 86 22:56:01 PST
    From: andy at hobbes.ads.ARPA (Andy Cromarty)

    A lot of MIT code (among other software) seems to contain the cliche'

    (define foo)				; Create an unbound instance of FOO
    (let ((some-lexical-var 'x))		; Create a closure....
          (set! foo (lambda () 		; Define outer FOO to reference
    		:			;  vars visible only in this lexenv.
    		:
    		)))

    This does not seem to be permitted, even optionally, by the existing R3RS,
    as far as I've noticed.  Did I miss something, or is it intentional that
    (DEFINE FOO) is not permitted, or was it an oversight?  I don't recall
    having seen discussion of this topic.

If you missed something then I did too.  I have no recollection of this
being discussed.

In trying to write portable Scheme code (it's difficult) I find myself
saying things like (define foo 'undefined) pretty often.  I don't find
this to be a major inconvenience, but it is an inconvenience.  I don't
see any serious problem with the (define foo) construct.  It would
presumably mean the same thing as (define foo <undefined>) where
<undefined> is that mysterious expression described in the discussion of
LETREC in section 7.3.  A correct immplementation of <undefined> would
of course be 'undefined (or just about anything else), the only
disadvantage of which is that it allow certain error situations to go
undetected.

For symmetry you'd want the syntax to be allowed for both internal
define's and top-level define's.  For this to work you'd have to apply the
(define foo) => (define foo <undefined>) rewrite before applying the
define => letrec rewrite.

This feature is implicitly permitted "optionally", because it is a
compatible extension.

Jonathan