From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: [patch] variable datums with syncase transformer Date: Wed, 05 Mar 2008 17:34:26 +0100 Message-ID: <87y78xqgdp.fsf@gnu.org> References: <1197619616.5218.34.camel@nocandy.dyndns.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1204734901 26272 80.91.229.12 (5 Mar 2008 16:35:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Mar 2008 16:35:01 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Mar 05 17:35:19 2008 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JWwaM-00082n-Nt for guile-devel@m.gmane.org; Wed, 05 Mar 2008 17:35:19 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JWwZp-00014z-9D for guile-devel@m.gmane.org; Wed, 05 Mar 2008 11:34:45 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JWwZj-00013l-QP for guile-devel@gnu.org; Wed, 05 Mar 2008 11:34:39 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JWwZi-00013Z-CX for guile-devel@gnu.org; Wed, 05 Mar 2008 11:34:39 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JWwZi-00013W-73 for guile-devel@gnu.org; Wed, 05 Mar 2008 11:34:38 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JWwZh-0000Em-Lq for guile-devel@gnu.org; Wed, 05 Mar 2008 11:34:38 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1JWwZf-0007m1-Nj for guile-devel@gnu.org; Wed, 05 Mar 2008 16:34:35 +0000 Original-Received: from 193.50.110.109 ([193.50.110.109]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Mar 2008 16:34:35 +0000 Original-Received: from ludo by 193.50.110.109 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 05 Mar 2008 16:34:35 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 65 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 193.50.110.109 X-Revolutionary-Date: 16 =?iso-8859-1?Q?Vent=F4se?= an 216 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEB1F5364 X-PGP-Key: http://www.laas.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 821D 815D 902A 7EAB 5CEE D120 7FBA 3D4F EB1F 5364 X-OS: i686-pc-linux-gnu User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:9tA9x3DE7oD/d/CrQSguD5/L/Ew= X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:7060 Archived-At: Stephen Compall writes: > ludo@gnu.org (Ludovic Courtès) writes: >> OTOH, you can (should?) use `use-modules': >> >> >> I don't even understand what the difference is between using >> `use-modules' and `use-syntax' for `(ice-9 syncase)'. > > guile> (use-modules (ice-9 syncase)) > guile> (define-syntax x-of-y > (lambda (stx) > (syntax-case stx () > (_ (syntax (hashq-ref y 'x)))))) > guile> x-of-y > # > > ;;restart > guile> ;;same as above, using use-syntax instead > guile> x-of-y > > Backtrace: > In unknown file: > ?: 0* [hashq-ref ... Oh, forgive my ignorance, I didn't know `syntax-case' allowed non-list patterns. It makes me like syntax transformers a bit more. ;-) Getting back to your initial problem... > guile> (use-syntax (ice-9 syncase)) > guile> (@ (guile) car) > ERROR: invalid syntax #> Note that `@' and `@@' rely on an interesting property of the evaluator: you type `(@ (guile) car)', `@' returns a *variable*, but what you get is a *procedure*, because in the meantime, the evaluator automagically performed a `variable-ref'. This is not very elegant in my opinion. With that in mind, I propose instead the following patch, which also fixes your problem AFAICS: --- /home/ludo/src/guile/1.8/guile-core/ice-9/boot-9.scm.~1.356.2.10.~ 2007-09-01 19:11:00.000000000 +0200 +++ /home/ludo/src/guile/1.8/guile-core/ice-9/boot-9.scm 2008-03-05 17:25:15.000000000 +0100 @@ -2988,7 +2988,7 @@ (let ((var (module-variable (resolve-interface mod-name) var-name))) (if (not var) (error "no such public variable" (list '@ mod-name var-name))) - var)) + (variable-ref var))) ;; The '@@' macro is like '@' but it can also access bindings that ;; have not been explicitely exported. @@ -2997,7 +2997,7 @@ (let ((var (module-variable (resolve-module mod-name) var-name))) (if (not var) (error "no such variable" (list '@@ mod-name var-name))) - var)) + (variable-ref var))) Would it be OK for you? Thanks, Ludovic.