From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Keith Wright Newsgroups: gmane.lisp.guile.user Subject: Re: Dynamic variable binding Date: Wed, 12 Nov 2008 19:51:27 -0500 Message-ID: <200811130051.mAD0pReg006490@fcs13.keithdiane.us> References: <8wro202o.fsf@vps203.linuxvps.org> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1226537616 2698 80.91.229.12 (13 Nov 2008 00:53:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 13 Nov 2008 00:53:36 +0000 (UTC) Cc: guile-user@gnu.org To: sebyte@smolny.plus.com Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Nov 13 01:54:37 2008 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L0QTe-0000Ol-UU for guile-user@m.gmane.org; Thu, 13 Nov 2008 01:54:31 +0100 Original-Received: from localhost ([127.0.0.1]:45146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0QSX-00058U-0r for guile-user@m.gmane.org; Wed, 12 Nov 2008 19:53:21 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L0QSS-00057f-NM for guile-user@gnu.org; Wed, 12 Nov 2008 19:53:16 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L0QSR-00057K-PS for guile-user@gnu.org; Wed, 12 Nov 2008 19:53:16 -0500 Original-Received: from [199.232.76.173] (port=49990 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0QSR-000579-H0 for guile-user@gnu.org; Wed, 12 Nov 2008 19:53:15 -0500 Original-Received: from mail3.sea5.speakeasy.net ([69.17.117.5]:49551) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L0QSR-0007cT-1u for guile-user@gnu.org; Wed, 12 Nov 2008 19:53:15 -0500 Original-Received: (qmail 16855 invoked from network); 13 Nov 2008 00:52:56 -0000 Original-Received: from dsl.keithdiane.us (HELO fcs12.keithdiane.us) ([66.92.74.188]) (envelope-sender ) by mail3.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 13 Nov 2008 00:52:55 -0000 Original-Received: from fcs13.keithdiane.us (fcs13 [192.168.1.112]) by fcs12.keithdiane.us (Postfix) with ESMTP id 05AB316B4A1; Wed, 12 Nov 2008 19:53:08 -0500 (EST) Original-Received: from fcs13.keithdiane.us (localhost.localdomain [127.0.0.1]) by fcs13.keithdiane.us (Postfix) with ESMTP id 1FA7EAF4043; Wed, 12 Nov 2008 19:51:38 -0500 (EST) Original-Received: (from kwright@localhost) by fcs13.keithdiane.us (8.13.1/8.13.1/Submit) id mAD0pReg006490; Wed, 12 Nov 2008 19:51:27 -0500 X-Authentication-Warning: fcs13.keithdiane.us: kwright set sender to kwright@keithdiane.us using -f In-reply-to: <8wro202o.fsf@vps203.linuxvps.org> (message from Sebastian Tennant on Wed, 12 Nov 2008 19:53:03 +0000) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:6893 Archived-At: > From: Sebastian Tennant > > guile> (define-macro (definer var val) > `(define ,var ,val)) > guile> (definer 'foo "bar") > guile> foo > ERROR: Unbound variable: foo > ABORT: (unbound-variable) > > No doubt this fails for the same reason this does: > > guile> (define 'foo "bar") > guile> foo > ERROR: Unbound variable: foo > ABORT: (unbound-variable) > > What exactly happens when you 'define' a symbol? I don't know what happens (in Guile), but I can tell you what _should_ happen. (In my humble opinion as a demi-god of semantics.) Scheme> (define 'foo "bar") at a very early stage (like in the reader) this is Scheme> (define (quote foo) "bar") There are several possiblities (1) error message in define (1a) Rude: Thou fool! |quote| is not a variable (1b) Polite: If you are sure you want to do that, write out the quote, don't use apostrophe (1c) Obscure: Bad variable in def_schkdt (2) Redefine quote (2a) In a new local scope: 'a is a call to procedure |quote| with argument the value of |a|, argument is evaluated, ignored, and 'a -> "bar" if |a| is defined. (2b) Hell breaks loose: All uses of |quote| in previously defined system procedures now have a new meaning. e.g. depending on exact code for |abs|, maybe (abs -3) -> "bar" But you are asking the wrong question. Ask not what happens when a symbol is defined, ask what you can do to make the macro define an unquoted variable. -- Keith PS: Experiments with an old version of Guile indicate (2). To distinguish (2a) from (2b) would require work or knowledge. guile> (version) "1.6.4" guile> (define 'foo "bar") guile> (quote 3) "bar" guile> '3 "bar" guile> 'foo standard input:6:4096: While evaluating arguments to quote in expression (quote foo): standard input:6:4096: Unbound variable: foo ABORT: (unbound-variable)