From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Dirk Herrmann Newsgroups: gmane.lisp.guile.devel Subject: Re: macros, procedure->macro Date: Wed, 10 Jul 2002 23:54:18 +0200 (CEST) Sender: guile-devel-admin@gnu.org Message-ID: References: <87n0t376c9.fsf@zagadka.ping.de> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: main.gmane.org 1026338098 5494 127.0.0.1 (10 Jul 2002 21:54:58 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 10 Jul 2002 21:54:58 +0000 (UTC) Cc: Gary Houston , guile-devel@gnu.org, guile-user@gnu.org Return-path: Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 17SPQH-0001QV-00 for ; Wed, 10 Jul 2002 23:54:57 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.35 #1 (Debian)) id 17SPQS-0005bb-00; Wed, 10 Jul 2002 17:55:08 -0400 Original-Received: from sallust.ida.ing.tu-bs.de ([134.169.132.52]) by fencepost.gnu.org with esmtp (Exim 3.35 #1 (Debian)) id 17SPPn-0005aw-00; Wed, 10 Jul 2002 17:54:27 -0400 Original-Received: from localhost (dirk@localhost) by sallust.ida.ing.tu-bs.de (8.9.3+Sun/8.9.1) with ESMTP id XAA16930; Wed, 10 Jul 2002 23:54:18 +0200 (CEST) Original-To: Marius Vollmer In-Reply-To: <87n0t376c9.fsf@zagadka.ping.de> Errors-To: guile-devel-admin@gnu.org X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.devel:784 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:784 On 7 Jul 2002, Marius Vollmer wrote: > 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 ""))) > (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. Just a side note: define-class cannot be used other than on top-level. The reason is, that define-class will define generic functions for accessors that are not defined yet. Getting this right in non-top-level scopes seems quite difficult (if not impossible) to do cleanly. > 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))) I am currently changing the definition of define-class accordingly. However, I am not sure which of the following solutions to choose: * use a helper function module-define-class. This would have to be exported. And, it could not be used like define-class, since you would not be able to pass an empty combination for an empty list of supers: (module-define-class some-module some-name () ...) would not be allowed, since you would have to quote the (). * use a helper macro module-define-class. This would have to be exported as syntax. * change the expanded code of define-class to hold all necessary instructions to do the module manipulations. In this case, the mmacro would return the following: `(begin ;; define accessors ,@(pre-definitions (slots exp) env) ;; update the current-module (let ((class (class ,@(cddr exp) #:name ',name))) (let* ((var (module-ensure-local-variable! (current-module) ',name)) (old (and (variable-bound? var) (variable-ref var)))) (if (and old (is-a? old ) (memq (class-precedence-list old))) (variable-set! var (class-redefinition old class)) (variable-set! var class)))))))))))) Which solution should be used? I will try to update define-generic and define-accessor accordingly. Best regards, Dirk Herrmann _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel