[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic variable binding

From: Sebastian Tennant
Subject: Re: Dynamic variable binding
Date: Fri, 19 Dec 2008 11:50:11 +0000
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux)

> Quoth Keith Wright <address@hidden>:
>> From: Sebastian Tennant <address@hidden>
>>  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")
 => "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'.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]