unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Sebastian Tennant <sebyte@smolny.plus.com>
To: guile-user@gnu.org
Subject: Re: Dynamic variable binding
Date: Fri, 19 Dec 2008 11:50:11 +0000	[thread overview]
Message-ID: <r644peoc.fsf@vps203.linuxvps.org> (raw)
In-Reply-To: 200811130051.mAD0pReg006490@fcs13.keithdiane.us

> Quoth Keith Wright <kwright@keithdiane.us>:
>> From: Sebastian Tennant <sebyte@smolny.plus.com>
>>
>>  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.)

I'm trying to wrap my head around symbols, variables and names of
variables.  They seem to me to be three different things.

> (define 'foo "bar")
>
> There are several possibilities
>
> (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

To be really semantically accurate should we not say:

(1a) Thou irrepressible fool! |quote| cannot be the _name_ of a variable.
(1c) Obscure: Bad variable _name_ in def_schkdt.

> 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.

Answer: Pass it an unquoted variable.

 (define-macro (definer var val)
   `(define ,var ,val))
 =>
 (definer foo "bar")
 =>
 foo
 => "bar"

 :)

Is that the answer you expected?

My semantic point is that the first argument to definer (above) is not a
symbol and it's not a variable (an unbound variable error would be
thrown if it was), so in the context of the first agument to define
there is a third data type; 'variable name'.

Sebastian





  reply	other threads:[~2008-12-19 11:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-12 19:53 Dynamic variable binding Sebastian Tennant
2008-11-12 22:05 ` Ludovic Courtès
2008-11-13  0:51 ` Keith Wright
2008-12-19 11:50   ` Sebastian Tennant [this message]
2008-12-19 13:03     ` Ludovic Courtès
2008-12-19 15:46       ` Sebastian Tennant
2008-12-20  0:17     ` Keith Wright
2008-12-27 15:56       ` Sebastian Tennant
2008-12-28 22:56         ` Neil Jerram
2008-12-29 10:48           ` Sebastian Tennant
2008-11-13 11:33 ` Sebastian Tennant
2008-11-13 18:50   ` Ludovic Courtès
2008-11-14  6:14     ` Sebastian Tennant
2008-11-15 14:58       ` Jon Wilson
2008-11-15 16:59         ` Sebastian Tennant
  -- strict thread matches above, loose matches on Subject: below --
2008-11-12 22:37 dsmich
     [not found] <200811130428.mAD4SQbi030880@cm-mail.stanford.edu>
2008-11-13 14:10 ` Kjetil S. Matheussen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=r644peoc.fsf@vps203.linuxvps.org \
    --to=sebyte@smolny.plus.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).