unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Dirk Herrmann <dirk@sallust.ida.ing.tu-bs.de>
Cc: Gary Houston <ghouston@arglist.com>,
	guile-devel@gnu.org, guile-user@gnu.org
Subject: Re: macros, procedure->macro
Date: Wed, 10 Jul 2002 23:54:18 +0200 (CEST)	[thread overview]
Message-ID: <Pine.GSO.4.05.10207102338290.16926-100000@sallust.ida.ing.tu-bs.de> (raw)
In-Reply-To: <87n0t376c9.fsf@zagadka.ping.de>

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 "<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.

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 <class>)
                  (memq <object> (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


  parent reply	other threads:[~2002-07-10 21:54 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87n0t376c9.fsf@zagadka.ping.de>
2002-07-08 20:23 ` macros, procedure->macro Dirk Herrmann
2002-07-09 18:13   ` Marius Vollmer
2002-07-10 21:54 ` Dirk Herrmann [this message]
2002-07-13  9:53   ` Dirk Herrmann
2002-07-13 18:38     ` Marius Vollmer
     [not found] <m3lm8e5o69.fsf@laruns.ossau.uklinux.net>
2002-07-14 21:35 ` Dirk Herrmann
2002-07-15 20:48   ` Marius Vollmer
2002-07-15 22:42   ` Neil Jerram
2002-07-16 22:00     ` Dirk Herrmann
     [not found] <200207012220.PAA08054@onyx.he.net>
2002-07-03 20:08 ` Dirk Herrmann
2002-07-04 20:16   ` Dirk Herrmann
2002-07-07 18:15     ` Marius Vollmer
2002-07-01 19:56 Dirk Herrmann
2002-07-01 21:30 ` Rob Browning
2002-07-03 20:24   ` Dirk Herrmann
2002-07-01 22:14 ` Marius Vollmer
2002-07-03 20:11   ` Dirk Herrmann
2002-07-07 17:54     ` Marius Vollmer
2002-07-08 20:31       ` Dirk Herrmann
2002-07-09 18:22         ` Marius Vollmer
2002-07-10  5:21           ` Dirk Herrmann
2002-07-10 19:31             ` Marius Vollmer
2002-07-10 19:57               ` Dirk Herrmann
2002-07-10 20:08                 ` Marius Vollmer
2002-07-01 22:17 ` Gary Houston
2002-07-09 21:16 ` Neil Jerram
2002-07-10  5:46   ` Dirk Herrmann
2002-07-10 10:15     ` Neil Jerram
2002-07-10 20:03       ` Dirk Herrmann
2002-07-13  0:09         ` Neil Jerram
2002-07-13  2:36           ` Clinton Ebadi
2002-07-14 15:23             ` Neil Jerram
2002-07-14 16:26               ` Marius Vollmer
2002-07-15  6:03                 ` Rob Browning
2002-07-13  6:53           ` Dirk Herrmann
2002-07-14 15:23             ` Neil Jerram

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.GSO.4.05.10207102338290.16926-100000@sallust.ida.ing.tu-bs.de \
    --to=dirk@sallust.ida.ing.tu-bs.de \
    --cc=ghouston@arglist.com \
    --cc=guile-devel@gnu.org \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).