From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Matt Wette Newsgroups: gmane.lisp.guile.user Subject: problems with syntax-case and with-syntax Date: Sun, 27 Aug 2017 13:18:20 -0700 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1503865151 9545 195.159.176.226 (27 Aug 2017 20:19:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 27 Aug 2017 20:19:11 +0000 (UTC) To: Guile User Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Aug 27 22:19:05 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dm41K-0001bl-Au for guile-user@m.gmane.org; Sun, 27 Aug 2017 22:18:58 +0200 Original-Received: from localhost ([::1]:35201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dm41L-000673-Uv for guile-user@m.gmane.org; Sun, 27 Aug 2017 16:18:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dm40t-00066x-2C for guile-user@gnu.org; Sun, 27 Aug 2017 16:18:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dm40o-0006cK-4b for guile-user@gnu.org; Sun, 27 Aug 2017 16:18:31 -0400 Original-Received: from mail-pg0-x22e.google.com ([2607:f8b0:400e:c05::22e]:33121) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dm40n-0006b2-Ul for guile-user@gnu.org; Sun, 27 Aug 2017 16:18:26 -0400 Original-Received: by mail-pg0-x22e.google.com with SMTP id t3so17621323pgt.0 for ; Sun, 27 Aug 2017 13:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=9dSE9mbR5CEQzBodKFhsQt0DHdCtFnuwyTHIYLK18zg=; b=gV8SbG2SqR/pg0WRdzTwjj3X6FoZLawr/hnD8FQtiZByzFs+vSdrqWQwZX22BzEgGY GXa4kRHj6dxYUYpx0C+czE+peBEznwLFrKpOgP6AWgvZ2+iTHeluccO3q7c1ZHjWUOba 1U/Z50h6yE3nWenn+0MRpzBAwQ67BwbDxk/bbxTMaSYYBbE5Reo2A+0CInE1BIDFQSUn sQ66dGOxc3qMP1Z8rBjfUDa9BEih4uSC7Ybiem1uRfxB8ik11kGMkzN7oYa9K74t7+kU KARUmp2PtMnDicgkuwnvv/5X1x8uPuxS74dXBzKn7SmKppnMEqCoFC6TN4B+TTvrE3lY LvHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=9dSE9mbR5CEQzBodKFhsQt0DHdCtFnuwyTHIYLK18zg=; b=t/HMN/uq/p1UZ9ilbx6Iz1+RPpr7F+QM2uzs/KoHdhLUjXvUz/G08uSkDXbImuHzE2 7UWBReSgwm2paOyXkpaKCSZws3aVExRRQ8/d+BQuh37Bqncf53APOLLRJR3pbCoVP4XW I/kB/4QRYxxSyZoAPaGUqhnNBpe8Au86XeKgMhwrTPvigSMJnvRWjC/VohVeLt7PyQI1 SrYgSavppzv6tWFdjdV8Gk35EDyWpYYCSN7wf4P3QLlntbnASqLyI5UFhbhoq+P3BtCN 3T3iHPetu24Y8zwp+uMdq+QA13D4cL1QbkpOKx0Gpk2tdKpJdkCP1fbkX3KqUWngE1Kl SyxA== X-Gm-Message-State: AHYfb5hwAjOwlsBKCq+OUSXT3cvneFX8hITzU5uJU+XXD33jqexc9jQO si8Al8aza7+aaITtQng= X-Received: by 10.99.149.73 with SMTP id t9mr5106056pgn.227.1503865102372; Sun, 27 Aug 2017 13:18:22 -0700 (PDT) Original-Received: from nautilus.championbroadband.com (216-165-229-229.championbroadband.com. [216.165.229.229]) by smtp.gmail.com with ESMTPSA id t123sm19180767pfb.73.2017.08.27.13.18.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Aug 2017 13:18:21 -0700 (PDT) X-Mailer: Apple Mail (2.3273) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22e X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14066 Archived-At: Q1) The code below creates two macros. One called `define-foo' which = generates a new identifier and=20 then defines that to #t. The other, `define-foo/p', generates the same = identifier (lexical issue?)=20 and another identifier, then "calls" define-foo and then uses both = identifiers in a `define'. When executed I get this error: scheme@(guile-user)> (define-foo/p abc) ;;; :2:0: warning: possibly unbound variable `wrap-abc' :2:0: :2:0: In procedure module-lookup: = Unbound variable: wrap-abc What am I doing wrong here? Q2) Also with respect to the code below. Is there any way to pull the = definitions for stx->str and gen-id out of the define-syntax body to make them general purpose? This code being developed under guile-2.2.2. The code: (define-syntax define-foo (lambda (x) (define (stx->str stx) (symbol->string (syntax->datum stx))) (define (gen-id tmpl-id . args) (datum->syntax tmpl-id (string->symbol (apply string-append (map (lambda (ss) (if (string? ss) ss (stx->str ss))) = args))))) (syntax-case x () ((_ name) (with-syntax ((wrap (gen-id x "wrap-" #'name))) #'(begin (define wrap #t))))))) (define-syntax define-foo/p (lambda (x) (define (stx->str stx) (symbol->string (syntax->datum stx))) (define (gen-id tmpl-id . args) (datum->syntax tmpl-id (string->symbol (apply string-append (map (lambda (ss) (if (string? ss) ss (stx->str ss))) = args))))) (syntax-case x () ((_ name) (with-syntax ((wrap (gen-id x "wrap-" #'name)) (rewrap (gen-id x "rewrap-" #'name))) #'(begin (define-foo name) (define rewrap wrap))))))) ;;(define-foo/p abc) ;; expect: ;; (define wrap-abc #t) ;; (define rewrap-abc wrap-abc) ;;(define-foo abc) ;; works (but does not define rewrap-abc ;; expect: ;; (define wrap-abc #t) Thanks for the help, Matt