guile-user
[Top][All Lists]
Advanced

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

Re: macros, procedure->macro


From: Marius Vollmer
Subject: Re: macros, procedure->macro
Date: 07 Jul 2002 20:15:02 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Dirk Herrmann <address@hidden> writes:

> So what is so special about the uses of procedure->macro at the places
> above?  
>
> [checking for redefinitions.]

We need to restrict this redefining behavior of 'define-class' et all
to the top-level.  Local class definitions should not redefine classes
outside of their scope (that would lead to a funny version of dynamic
scoping of classes, eew), and redefinitions directly in one scope
should be an error, just like any other definitions.

For example,

    (let ((foo (find-class "<moo>")))
      (define-class foo ...)
      ...)

should not try to redefine the class that is the value of the location
bound to foo by the let.  It should simply shadow the outer foo.

Also,

    (let ()
      (define-class foo ...)
      (define-class foo ...)
      ...)

should be an error, just like

    (let ()
      (define foo ...)
      (define foo ...))

Redefinitions on the top-level do make sense and can be supported by a
normal macro via explicit module manipulations, i.e.

    (define-class foo ...)
    =>
    (module-define-class (current-module) 'foo ...)

with

    (define (module-define-class mod sym ...)
      (let* ((var (module-ensure-local-variable! mod 'foo))
             (class (make-class ...)))
        (if (variable-bound? var)
            (redefine-class (variable-ref var) class))
        (variable-set! var class)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]