guile-devel
[Top][All Lists]
Advanced

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

Re: Fwd: [Patch] definitions in when, unless, do as well as in cond- and


From: Stefan Israelsson Tampe
Subject: Re: Fwd: [Patch] definitions in when, unless, do as well as in cond- and case-clauses
Date: Sat, 5 Feb 2022 02:14:34 +0100

For conditional variables you gave a default value. So then why on earth do you not have an implicit let ?
There must be a good reason.

On Sat, Feb 5, 2022 at 12:39 AM Maxime Devos <maximedevos@telenet.be> wrote:
Stefan Israelsson Tampe schreef op vr 04-02-2022 om 22:40 [+0100]:
> Anyhow conditional defining vars is a common theme in other languages
> so I think it was kind of natural to implement if as it was done.

AFAIK no Lisp or Scheme except for Guile < 2.0 implements conditionally
defining local variables (but then I usually only consider Guile Scheme
and the RnRS, so this doesn't mean much).  In my experience, I have
never seen a need for conditionally defining a local variable in Scheme
code (if you have a real-world example, please share).

It also seems impossible to implement this w.r.t. the macro system ---
what should, say, bound-identifier=? do when one of its identifiers is
only conditionally bound?  Or for another example:

If I do

(define foo 'bar)
(define-syntax foobar
  (syntax-rules (foo)
    ((_ foo)
     (begin (pk "it's a foo!") foo))
    ((_ goo)
     (begin (pk "it's not a foo ...") goo))))

(define (zebra stripes)
  (if stripes
      (define foo 'quux))
  (foobar foo)) ;; <--- ***

then sometimes the 'foo' in '***' refers to the global variable 'foo'
and hence 'foobar' expands to the "it's a foo'.'  Sometimes the 'foo'
in '***' refers to the local variable 'foo' (!= the global foo) hence
'foobar' expands to the "it's not a foo ...".

However, it's impossible for a macro to expand to multiple things at
once!

Greetings,
Maxime.

reply via email to

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