From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: taylanbayirli@gmail.com (Taylan Ulrich =?UTF-8?Q?Bay=C4=B1rl=C4=B1/Kammer?=) Newsgroups: gmane.lisp.guile.bugs Subject: bug#21379: datum->syntax chokes on lists of syntax objects Date: Sun, 30 Aug 2015 10:31:09 +0200 Message-ID: <87wpwdgotu.fsf@T420.taylan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1440923545 1746 80.91.229.3 (30 Aug 2015 08:32:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 30 Aug 2015 08:32:25 +0000 (UTC) To: 21379@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sun Aug 30 10:32:10 2015 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZVy24-0005Bq-Px for guile-bugs@m.gmane.org; Sun, 30 Aug 2015 10:32:09 +0200 Original-Received: from localhost ([::1]:57572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVy23-0005mU-T3 for guile-bugs@m.gmane.org; Sun, 30 Aug 2015 04:32:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVy1z-0005mH-SG for bug-guile@gnu.org; Sun, 30 Aug 2015 04:32:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZVy1y-0006B8-PU for bug-guile@gnu.org; Sun, 30 Aug 2015 04:32:03 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVy1y-0006B4-Mg for bug-guile@gnu.org; Sun, 30 Aug 2015 04:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZVy1y-0001WE-Gy for bug-guile@gnu.org; Sun, 30 Aug 2015 04:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: taylanbayirli@gmail.com (Taylan Ulrich =?UTF-8?Q?Bay=C4=B1rl=C4=B1/Kammer?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 30 Aug 2015 08:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21379 X-GNU-PR-Package: guile X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14409234785783 (code B ref -1); Sun, 30 Aug 2015 08:32:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Aug 2015 08:31:18 +0000 Original-Received: from localhost ([127.0.0.1]:42483 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZVy1F-0001VC-Rd for submit@debbugs.gnu.org; Sun, 30 Aug 2015 04:31:18 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:32806) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZVy1D-0001V4-75 for submit@debbugs.gnu.org; Sun, 30 Aug 2015 04:31:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZVy1B-0005uh-N9 for submit@debbugs.gnu.org; Sun, 30 Aug 2015 04:31:14 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:55581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVy1B-0005uX-Kg for submit@debbugs.gnu.org; Sun, 30 Aug 2015 04:31:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVy1A-0005jH-Ix for bug-guile@gnu.org; Sun, 30 Aug 2015 04:31:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZVy19-0005tE-E8 for bug-guile@gnu.org; Sun, 30 Aug 2015 04:31:12 -0400 Original-Received: from mail-wi0-x22c.google.com ([2a00:1450:400c:c05::22c]:38735) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVy19-0005t3-5v for bug-guile@gnu.org; Sun, 30 Aug 2015 04:31:11 -0400 Original-Received: by wicpl12 with SMTP id pl12so2671705wic.1 for ; Sun, 30 Aug 2015 01:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type; bh=4SySEFA0Tdkmou2YlI8V/xXED3gHu5NAVWX46xaeDXA=; b=H28zvZuyiPe+VfpoQUYwrTvdWXKsixHq6ybokTf2oGzLMIQcFUK0dwd8vhuLKKrH0p ndnnWNbe3HArG/nZPNOkDl6mSZNJYc0cL7oQ7dUFZikc98411fbcEl+FJp9nZn2ukvqK kPS+TZIxtwk02nzLH/mlihYvgUfvFKr8DmTcHJvojUi8QXdQyDydamBn6/v90+jH0lsX VdXOUxJDjMYnNe8r0Ocj/Kj63YgLkAt0/OGJvY4L6D3t6lt6X2DbZ4cKeeIQZzgtRnWm DhJO9IB+luwQkw9Uz9IyOAnsoQdtZpAiEn9kBhuMWi4YwnbbGbjFCgdyDysEQRZW1qAV ogUQ== X-Received: by 10.194.117.133 with SMTP id ke5mr20504881wjb.116.1440923470610; Sun, 30 Aug 2015 01:31:10 -0700 (PDT) Original-Received: from T420.taylan ([2a02:908:c32:4740:221:ccff:fe66:68f0]) by smtp.gmail.com with ESMTPSA id v9sm16336303wjq.41.2015.08.30.01.31.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Aug 2015 01:31:09 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7831 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Amend-datum-syntax-documentation.patch >From 9578ee36ef005f0b96c1d5b120f11c178e341775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?= 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 --=-=-=--