GNU bug report logs - #21379
datum->syntax chokes on lists of syntax objects

Previous Next

Package: guile;

Reported by: taylanbayirli <at> gmail.com (Taylan Ulrich Bayırlı/Kammer)

Date: Sun, 30 Aug 2015 08:32:02 UTC

Severity: normal

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: taylanbayirli <at> gmail.com (Taylan Ulrich
 Bayırlı/Kammer)
Subject: bug#21379: closed (Re: bug#21379: datum->syntax chokes on lists
 of syntax objects)
Date: Wed, 02 Sep 2015 18:13:03 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#21379: datum->syntax chokes on lists of syntax objects

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 21379 <at> debbugs.gnu.org.

-- 
21379: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21379
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Mark H Weaver <mhw <at> netris.org>
To: taylanbayirli <at> gmail.com (Taylan Ulrich "Bayırlı/Kammer")
Cc: 21379-done <at> debbugs.gnu.org
Subject: Re: bug#21379: datum->syntax chokes on lists of syntax objects
Date: Wed, 02 Sep 2015 14:11:03 -0400
taylanbayirli <at> gmail.com (Taylan Ulrich "Bayırlı/Kammer") writes:

> From 2ba9474dc8e2a56524d8c6c2f640fb3fb35b2d14 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
>  <taylanbayirli <at> gmail.com>
> Date: Sun, 30 Aug 2015 10:24:52 +0200
> Subject: [PATCH] Amend datum->syntax documentation.

Pushed with minor changes: I changed "Amend" to "Clarify" in the summary
line, and updated the copyright dates in api-macros.texi.

    Thanks!
      Mark

[Message part 3 (message/rfc822, inline)]
From: taylanbayirli <at> gmail.com (Taylan Ulrich Bayırlı/Kammer)
To: bug-guile <at> gnu.org
Subject: datum->syntax chokes on lists of syntax objects
Date: Sun, 30 Aug 2015 10:31:09 +0200
[Message part 4 (text/plain, inline)]
Apparently there's two ways to represent a list syntax object:

    (datum->syntax #'x '(a b c))
    => #(syntax-object (a b c) ((top)) (hygiene guile-user))

i.e. a syntax object vector with a list payload, and

    #'(a b c)
    => (#(syntax-object a ((top)) (hygiene guile-user))
        #(syntax-object b ((top)) (hygiene guile-user))
        #(syntax-object c ((top)) (hygiene guile-user)))

i.e. a list of the elements as syntax objects.

Syntax-case and syntax->datum work fine with both.  But when the latter
form is used as the first argument to a datum->syntax call, it leads to
an error:

--- snip
scheme@(guile-user)> (datum->syntax #'(x) '(a b c))
ice-9/psyntax.scm:467:4: In procedure datum->syntax:
ice-9/psyntax.scm:467:4: In procedure vector-ref: Wrong type argument in position 1 (expecting vector): (#(syntax-object x ((top)) (hygiene guile-user)))

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]>
--- snip

I think I understand the problem: in case of a list of syntax objects,
it's ambiguous which one's environment should be used for the newly
created syntax object, so it requires it to be an "immediately wrapped"
syntax object instead.  (By the way, the psyntax sources actually call
that argument 'id', hinting that perhaps it's expected to be an
identifier, though the other representation works fine.)

I have no clue what's the best way to solve this, but if my
understanding is correct, it's a fundamental issue with datum->syntax
and not a bug, so here's a documentation patch that tries to explain the
limitation.

[0001-Amend-datum-syntax-documentation.patch (text/x-diff, inline)]
From 9578ee36ef005f0b96c1d5b120f11c178e341775 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
 <taylanbayirli <at> gmail.com>
Date: Sun, 30 Aug 2015 10:24:52 +0200
Subject: [PATCH] Amend datum->syntax documentation.

* doc/ref/api-macros.texi (Syntax Case): Mention that the first argument
  to datum->syntax is invalid if it's a compound syntax object, except
  when also created with datum->syntax.
---
 doc/ref/api-macros.texi | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/doc/ref/api-macros.texi b/doc/ref/api-macros.texi
index c2910a4..9c1f023 100644
--- a/doc/ref/api-macros.texi
+++ b/doc/ref/api-macros.texi
@@ -618,7 +618,12 @@ But they can, if we explicitly introduce a binding via @code{datum->syntax}.
 
 @deffn {Scheme Procedure} datum->syntax for-syntax datum
 Create a syntax object that wraps @var{datum}, within the lexical context
-corresponding to the syntax object @var{for-syntax}.
+corresponding to the syntax object @var{for-syntax}.  @var{for-syntax} must
+either be an identifier, or a syntax object that was also created with
+@var{datum->syntax}; other compound syntax objects may be rejected because they
+contain identifiers from different lexical contexts, in which case it would be
+ambiguous which one's environment should be used for the newly created syntax
+object.
 @end deffn
 
 For completeness, we should mention that it is possible to strip the metadata
-- 
2.5.0


This bug report was last modified 9 years and 319 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.