unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* empty syntax objects
@ 2009-10-20  2:44 Julian Graham
  2009-10-20 19:22 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Julian Graham @ 2009-10-20  2:44 UTC (permalink / raw)
  To: guile-devel

Hi all,

This is a weird one.  It looks like there's a problem with performing
certain operations on syntax objects that "wrap" the empty list -- I
think because such syntax objects are themselves indistinguishable
from the empty list.  I'm still not sure I fully understand what's
going on, but suffice it to say that if you have a syntax-case
expression that looks like:

(syntax-case x ()
  ((foo . rest)
   (datum->syntax #'rest 'foo)))

...you get an error if `foo' is expanded without anything to bind to `rest':

;;; key wrong-type-arg, throw_args (#f "Wrong type argument in
position ~A: ~S" (2 2) (2))

You can get the same error via the following code:

(datum->syntax #'() 'foo)

The initial error message didn't include any source information, so I
connected to the process with gdb and dug around in psyntax-pp.scm
until I located the following line (5459), which seems to be the
culprit:

(#{syntax-object-wrap\ 116}#
  (lambda (#{x\ 783}#) (vector-ref #{x\ 783}# 2)))

What's the right thing to do here?  Do you just have to be careful
with what you do with pattern variables that might end up getting
bound to no arguments?  R6RS isn't totally clear on the topic, but,
for what it's worth, the same code seems to work in MzScheme.


Regards,
Julian




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

* Re: empty syntax objects
  2009-10-20  2:44 empty syntax objects Julian Graham
@ 2009-10-20 19:22 ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2009-10-20 19:22 UTC (permalink / raw)
  To: Julian Graham; +Cc: guile-devel

Hi Daniel,

On Tue 20 Oct 2009 04:44, Julian Graham <joolean@gmail.com> writes:

> (syntax-case x ()
>   ((foo . rest)
>    (datum->syntax #'rest 'foo)))
>
> ...you get an error if `foo' is expanded without anything to bind to
> `rest':

I downloaded Petite Chez Scheme today and tried this out. I also got an
error. I suspect you would get an error with ikarus or other
psyntax-using implementations as well.

> What's the right thing to do here?  Do you just have to be careful
> with what you do with pattern variables that might end up getting
> bound to no arguments?  R6RS isn't totally clear on the topic, but,
> for what it's worth, the same code seems to work in MzScheme.

I think for now the story would just be to be careful, unless you are in
possession of a +12 Cloak of Psyntax Hack :)

Andy
-- 
http://wingolog.org/




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

end of thread, other threads:[~2009-10-20 19:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-20  2:44 empty syntax objects Julian Graham
2009-10-20 19:22 ` Andy Wingo

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