unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* namespace of goops module
@ 2006-02-14 17:14 William Xu
  2006-02-14 21:12 ` Clinton Ebadi
  2006-02-14 22:43 ` Neil Jerram
  0 siblings, 2 replies; 7+ messages in thread
From: William Xu @ 2006-02-14 17:14 UTC (permalink / raw)


Hi people there, 

I try to learn GOOP today. As i don't want to mess with name conficts, i
decided to add a prefix while using any modules. Thus to load GOOPS, 

guile> (use-modules ((oop goops) :renamer (symbol-prefix-proc 'oop/goops:)))

This seems okay. While, when i try the first example in GOOPS Info, 

guile> (oop/goops:define-method (+ (x <string>) (y <string>))
       (string-append x y))
<unnamed port>: In expression (add-method! + (method # #)):
<unnamed port>: Unbound variable: add-method!
ABORT: (unbound-variable)

Type "(backtrace)" to get more information or "(debug)" to enter the debugger.
guile> 

Seems i can't add a renamer for goops module, but make it available on
top-level? While, GOOPS is not built in guile, is it?

So what's the point here?

-- 
William


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: namespace of goops module
  2006-02-14 17:14 namespace of goops module William Xu
@ 2006-02-14 21:12 ` Clinton Ebadi
  2006-02-15  2:02   ` William Xu
  2006-02-14 22:43 ` Neil Jerram
  1 sibling, 1 reply; 7+ messages in thread
From: Clinton Ebadi @ 2006-02-14 21:12 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 1499 bytes --]

On Wed, 2006-02-15 at 01:14 +0800, William Xu wrote:
> Hi people there, 
> 
> I try to learn GOOP today. As i don't want to mess with name conficts, i
> decided to add a prefix while using any modules. Thus to load GOOPS, 
> 
> guile> (use-modules ((oop goops) :renamer (symbol-prefix-proc 'oop/goops:)))
> 
> This seems okay. While, when i try the first example in GOOPS Info, 
> 
> guile> (oop/goops:define-method (+ (x <string>) (y <string>))
>        (string-append x y))
> <unnamed port>: In expression (add-method! + (method # #)):
> <unnamed port>: Unbound variable: add-method!
> ABORT: (unbound-variable)
> 
> Type "(backtrace)" to get more information or "(debug)" to enter the debugger.
> guile> 
> 
> Seems i can't add a renamer for goops module, but make it available on
> top-level? While, GOOPS is not built in guile, is it?
> 
> So what's the point here?

The GOOPS macros (e.g. define-method) are not hygenic, and are not
evaluated in the defining module, but rather the current one. The Guile
module system does not (yet? Perhaps never since r6rs will have an
incompatible module system that deals with such things, and there isn't
much point to pushing the guile system except for compatibility after
r6rs) deal with macros very well.

-- 
http://unknownlamer.org
AIM:unknownlamer IRC:unknown_lamer@fnode#tpu Jabber:clinton@hcoop.net
I use Free Software because I value freedom over features.
443E 4F1A E213 7C54 A306  E328 7601 A1F0 F403 574B

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: namespace of goops module
  2006-02-14 17:14 namespace of goops module William Xu
  2006-02-14 21:12 ` Clinton Ebadi
@ 2006-02-14 22:43 ` Neil Jerram
  2006-02-15 22:22   ` Kevin Ryde
  1 sibling, 1 reply; 7+ messages in thread
From: Neil Jerram @ 2006-02-14 22:43 UTC (permalink / raw)
  Cc: guile-user

William Xu <william.xwl@gmail.com> writes:

> guile> (use-modules ((oop goops) :renamer (symbol-prefix-proc 'oop/goops:)))
>
> This seems okay. While, when i try the first example in GOOPS Info, 
>
> guile> (oop/goops:define-method (+ (x <string>) (y <string>))
>        (string-append x y))
> <unnamed port>: In expression (add-method! + (method # #)):
> <unnamed port>: Unbound variable: add-method!
> ABORT: (unbound-variable)
>
> Type "(backtrace)" to get more information or "(debug)" to enter the debugger.
> guile> 
>
> Seems i can't add a renamer for goops module, but make it available on
> top-level? While, GOOPS is not built in guile, is it?
>
> So what's the point here?

Hmm, it looks like the point is that renaming won't work when a module
defines a macro (with either defmacro or define-macro) whose expansion
includes one of that module's own bindings.

Interesting problem.  I think it should work for the macro definition
to unquote such bindings, so that they are looked up in the module's
environment at definition time rather than later in the caller's
environment.  In other words,

(define-macro (whatever ...)
  `(,what* ...))

rather than

(define-macro (whatever ...)
  `(what* ...))

To make progress in the short term, though, I think you'll have to use
(oop goops) without a renamer.

    Neil 



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: namespace of goops module
  2006-02-14 21:12 ` Clinton Ebadi
@ 2006-02-15  2:02   ` William Xu
  2006-02-15 11:39     ` Andy Wingo
  0 siblings, 1 reply; 7+ messages in thread
From: William Xu @ 2006-02-15  2:02 UTC (permalink / raw)


Clinton Ebadi <clinton@unknownlamer.org> writes:

[...]

> The GOOPS macros (e.g. define-method) are not hygenic, and are not
> evaluated in the defining module, but rather the current one. 

Ah, it sounds as a good enhancement of hygenic macros over CL-sytle
macros. As guile provides both of them, sometimes i'm confused of which
one to use. Is it a good idea to use only hygenic macros? Anyway, R5RS
has defined only hygenic macros.

> The Guile module system does not (yet? Perhaps never since r6rs will
> have an incompatible module system that deals with such things, and
> there isn't much point to pushing the guile system except for
> compatibility after r6rs) deal with macros very well.

Ugh, so we have to wait...

ps. Supposed i defined a syntax `when', if i want to check out what
`when' is, either a function, macro, or syntax, like, 

guile> when
ERROR: invalid syntax when
ABORT: (misc-error)
guile> 

For several times at first, this made me think that i might have done
some wrong in the definition of `when', but i haven't actually. This
seems a little weird. Isn't it more intuitive to prompt, say, 

guile> when
#<syntax! when>
guile>

Or is it also an undefined behaviour in the standards?

And, the rule of placing docstring at the first line in the definition
body, so as to be able to retrieve later by (help name), doesn't apply
to a syntax definition?

-- 
William


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: namespace of goops module
  2006-02-15  2:02   ` William Xu
@ 2006-02-15 11:39     ` Andy Wingo
  2006-02-15 15:42       ` William Xu
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Wingo @ 2006-02-15 11:39 UTC (permalink / raw)


Hi,

On Wed, 2006-02-15 at 10:02 +0800, William Xu wrote:
> ps. Supposed i defined a syntax `when', if i want to check out what
> `when' is, either a function, macro, or syntax, like, 
> 
> guile> when
> ERROR: invalid syntax when
> ABORT: (misc-error)

syntax-rules macros are not first-class objects

> guile> when
> #<syntax! when>

acros are however

Guile's macro system is, um, "evolved". As in there are some warts like
this.

> [I]s it also an undefined behaviour in the standards?

Yup.

> And, the rule of placing docstring at the first line in the definition
> body, so as to be able to retrieve later by (help name), doesn't apply
> to a syntax definition?

Nope. Syntaxen are hard to document. There's some stuff in guile-lib for
pulling docstrings out of defmacros (the ones made by define-macro),
though. I prefer defmacros to syncase, fwiw.

Regards,
-- 
Andy Wingo
http://wingolog.org/



_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: namespace of goops module
  2006-02-15 11:39     ` Andy Wingo
@ 2006-02-15 15:42       ` William Xu
  0 siblings, 0 replies; 7+ messages in thread
From: William Xu @ 2006-02-15 15:42 UTC (permalink / raw)


Andy Wingo <wingo@pobox.com> writes:

> Nope. Syntaxen are hard to document. There's some stuff in guile-lib for
> pulling docstrings out of defmacros (the ones made by define-macro),
> though. I prefer defmacros to syncase, fwiw.

While defmacros would cause the renamer problem, as described in my
original post? Don't know how common lisp handles this..

-- 
William


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: namespace of goops module
  2006-02-14 22:43 ` Neil Jerram
@ 2006-02-15 22:22   ` Kevin Ryde
  0 siblings, 0 replies; 7+ messages in thread
From: Kevin Ryde @ 2006-02-15 22:22 UTC (permalink / raw)


Neil Jerram <neil@ossau.uklinux.net> writes:
>
> (define-macro (whatever ...)
>   `(,what* ...))

That'd be the idea, works nicely with procedures, but I had trouble
unquoting macros/syntax bits.  In the new guile 1.8 `while' in
boot-9.scm unquoting the `do' made (ice-9 syncase) very upset.


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-02-15 22:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-14 17:14 namespace of goops module William Xu
2006-02-14 21:12 ` Clinton Ebadi
2006-02-15  2:02   ` William Xu
2006-02-15 11:39     ` Andy Wingo
2006-02-15 15:42       ` William Xu
2006-02-14 22:43 ` Neil Jerram
2006-02-15 22:22   ` Kevin Ryde

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