[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in eval-string?
From: |
Matthias Koeppe |
Subject: |
Re: Bug in eval-string? |
Date: |
Mon, 12 Aug 2002 20:20:30 +0200 |
User-agent: |
Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1.80 (sparc-sun-solaris2.7) |
Marius Vollmer <address@hidden> writes:
> Matthias Koeppe <address@hidden> writes:
>
>> > But "with" is such a nice name compared to "fluid-let"! ;)
>>
>> The name is *too nice* for something like FLUID-LET. Remember, it
>> uses DYNAMIC-WIND and lots of SET!s. It is inefficient if CALL/CC
>> is used.
>
> Hmm, what is wrong with 'dynamic-wind' and 'set!'?
I would like to refer you to the discussion archive of SRFI-15.
http://srfi.schemers.org/srfi-15/mail-archive/maillist.html
>> It won't work in a threaded environment.
>
> Really? Whether or not the dynamic context established by "with" or
> "fluid-let" is local to the current thread or gloabal to all depends
> on the nature of the 'variable' that you are setting. It could be a
> fluid, or it could be an ordinray global variable.
1. If you provide an overly convenient construct named "WITH", people
will write code (and libraries) using it for dynamic scoping,
rather than using fluid variables with the right dynamic-scoping
construct, WITH-FLUIDS.
All this code will not be re-usable in a threaded environment.
2. As a side note, let us see how FLUID-LET looks if you want to
use it with real fluids:
(fluid-let (((fluid-ref my-fluid) value))
...code...)
Using WITH-FLUIDS would certainly be prettier here:
(with-fluids ((my-fluid value))
...code...)
>> > I'd say that fluid-let should be in the core. Opinions?
>>
>> I'd say, we should rather make SLIB integration smoother, and/or
>> provide a SRFI-15 implementation (despite its withdrawn status).
>>
>> Putting it in the core won't be a good idea IMHO.
>>
>> 1) It creates confusion because Guile knows real fluid variables.
>> FLUID-LET has "fluid" in its name but has no connection to
>> fluids.
>
> That's actually one reason why I like "with".
I will comment on the name "WITH" at the end of this message.
>> 2) WITH-FLUIDS is much cleaner than FLUID-LET. People should use
>> WITH-FLUIDS if they want (threadsafe) dynamic scoping.
>
> But with-fluids is only for fluids, not for general dynamic scoping of
> settable things.
I don't think it is a good idea to introduce core syntax for a
dynamic-scoping hack for general "settable things".
I certainly don't want to see code like this:
(fluid-let (((caddr l) (...))
((list-ref l 17) (...)))
...)
What "general settable things" did you have in mind? The application
that the original poster had (setting the current-module for
eval-string) certainly is not an example of typical use.
> [...]
> So I don't see how offering "fluid-let" or "with" is dangerous. It
> might not be 'pure', but it offers something that people want to use.
> having to use dynamic-wind explicitely is cumbersome and error prone
> compared to fluid-let, in my view.
It's not mainly about "purity", it's about code re-usability for a
threaded environment.
Guile already offers something that people want to use, and it is
called WITH-FLUIDS.
I guess it should simply be advertised better. In fact, in the
current Guile manual, fluids currently only appear in the esoteric
chapter "Threads, Mutexes, Asyncs and Dynamic Roots", which is also
marked as a "FIXME" chapter. (BTW, the syntax WITH-FLUIDS is missing
there, only the procedure WITH-FLUIDS* is explained.)
I believe we should move the discussion of fluids to a more prominent
place of the Guile manual. They should be advertised as _the_
construct in Guile for dealing with dynamical scope.
* * *
Users who really want to use the FLUID-LET hack can use SLIB. (Does
SLIB integration work well in Guile?)
Adding FLUID-LET to the core would create confusion because of Guile's
fluid variables, as I mentioned.
Adding it to the core under the name WITH is a bad idea because:
A. Nobody else in the Scheme community seems to call FLUID-LET
"WITH".
B. "WITH" is a far too generic name for something like FLUID-LET.
C. It does not fit at all into the Scheme naming scheme. We have
WITH-INPUT-FROM-FILE, WITH-OUTPUT-TO-FILE, and some other
WITH-... procedures, but their name always says with "what" the
passed thunk (or body) is called. If you wanted "WITH..." syntax
for FLUID-LET, it would be something like
WITH-DYNAMICALLY-WOUND-VALUES.
D. Because of reason 1 above.
My conclusion: Adding "FLUID-LET" to the Guile core only creates
problems, no matter whether it is added under its traditional name or
as "WITH". (Having it in the core certainly won't help in any way to
make Emacs switch to Guile, BTW.)
Regards,
--
Matthias Köppe -- http://www.math.uni-magdeburg.de/~mkoeppe
- Bug in eval-string?, rm, 2002/08/08
- Re: Bug in eval-string?, Marius Vollmer, 2002/08/08
- Re: Bug in eval-string?, Matthias Koeppe, 2002/08/09
- Re: Bug in eval-string?, Marius Vollmer, 2002/08/09
- Re: Bug in eval-string?, Matthias Koeppe, 2002/08/09
- Re: Bug in eval-string?, Marius Vollmer, 2002/08/10
- Re: Bug in eval-string?,
Matthias Koeppe <=
- Re: Bug in eval-string?, Marius Vollmer, 2002/08/12
- Re: Bug in eval-string?, Marius Vollmer, 2002/08/14
- Re: Bug in eval-string?, Neil Jerram, 2002/08/19
- Re: Bug in eval-string?, Matthias Koeppe, 2002/08/20
- Re: Bug in eval-string?, Marius Vollmer, 2002/08/21
- Emacs variables (was: Bug in eval-string?), Matthias Koeppe, 2002/08/27
- Re: Emacs variables (was: Bug in eval-string?), Marius Vollmer, 2002/08/31
Re: Bug in eval-string?, Neil Jerram, 2002/08/08