unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* export in syntax-rules
@ 2003-01-26 23:12 Kevin Ryde
  2003-01-27 11:23 ` Mikael Djurfeldt
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Ryde @ 2003-01-26 23:12 UTC (permalink / raw)


In guile 1.6.1 on a recent i386 debian, I thought to use "export"
inside a syntax-rules in a module definition, for instance

    (define-module (abc def)
      #:use-module (ice-9 syncase))

    (define-syntax foo
      (syntax-rules ()
        ((foo name)
         (export name))))

    (define x 123)
    (foo x)

But I got an error,

    ERROR: In procedure variable-ref:
    ERROR: Wrong type argument in position 1 (expecting variable): #f

Is this sort of thing meant to work, or have I made some basic error?

(I was looking to make "-public" versions of some macros.  I got the
effect I wanted with a procedure->macro, but just wondered if the
syntax-rules style was valid.)


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


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

* Re: export in syntax-rules
  2003-01-26 23:12 export in syntax-rules Kevin Ryde
@ 2003-01-27 11:23 ` Mikael Djurfeldt
  2003-02-01  0:49   ` Kevin Ryde
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Djurfeldt @ 2003-01-27 11:23 UTC (permalink / raw)
  Cc: guile-user

Kevin Ryde <user42@zip.com.au> writes:

> In guile 1.6.1 on a recent i386 debian, I thought to use "export"
> inside a syntax-rules in a module definition, for instance
>
>     (define-module (abc def)
>       #:use-module (ice-9 syncase))

You might want to use #:use-syntax (ice-9 syncase) here instead,
otherwise syntax-case expansion is only invoked when syntax-case
macros are called in an s-expression.  That disables singleton macros
and can cause unexpected errors with regard to scope.

>     (define-syntax foo
>       (syntax-rules ()
>         ((foo name)
>          (export name))))
>
>     (define x 123)
>     (foo x)
>
> But I got an error,
>
>     ERROR: In procedure variable-ref:
>     ERROR: Wrong type argument in position 1 (expecting variable): #f
>
> Is this sort of thing meant to work, or have I made some basic error?
>
> (I was looking to make "-public" versions of some macros.  I got the
> effect I wanted with a procedure->macro, but just wondered if the
> syntax-rules style was valid.)

This is caused by a bug in syncase.scm.  I've fixed this in CVS 1.7.0
and in the 1.6 branch.  1.6.2 will contain the fix.

2003-01-27  Mikael Djurfeldt  <djurfeldt@nada.kth.se>

	* syncase.scm (guile-macro): Strip syntactic information from
	expression before trying to treat it as a Guile macro call.
	(Thanks to Kevin Ryde.)


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


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

* Re: export in syntax-rules
  2003-01-27 11:23 ` Mikael Djurfeldt
@ 2003-02-01  0:49   ` Kevin Ryde
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Ryde @ 2003-02-01  0:49 UTC (permalink / raw)


Mikael Djurfeldt <djurfeldt@nada.kth.se> writes:
>
> You might want to use #:use-syntax (ice-9 syncase) here instead,
> otherwise syntax-case expansion is only invoked when syntax-case
> macros are called in an s-expression.  That disables singleton macros
> and can cause unexpected errors with regard to scope.

Oh, I see, say "(display foo)" gets foo expanded (as invalid I guess)
under use-syntax, but not under use-modules.

Tricky stuff.  I put use-module without really paying attention to the
doco, and it worked, so I thought no more of it :-).


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


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

end of thread, other threads:[~2003-02-01  0:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-26 23:12 export in syntax-rules Kevin Ryde
2003-01-27 11:23 ` Mikael Djurfeldt
2003-02-01  0:49   ` 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).