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: Maxime Devos
Subject: Re: Fwd: [Patch] definitions in when, unless, do as well as in cond- and case-clauses
Date: Sat, 05 Feb 2022 00:39:03 +0100
User-agent: Evolution 3.38.3-1

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.

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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