From: Andy Wingo <wingo@pobox.com>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-devel@gnu.org
Subject: Re: How can I tell guile to shut up? ;)
Date: Fri, 01 Jul 2011 10:16:29 +0200 [thread overview]
Message-ID: <87zkky8lgi.fsf@pobox.com> (raw)
In-Reply-To: <871uyb1030.fsf@gnu.org> ("Ludovic Courtès"'s message of "Thu, 30 Jun 2011 23:27:47 +0200")
Hi!
Thanks for thinking this through!
On Thu 30 Jun 2011 23:27, ludo@gnu.org (Ludovic Courtès) writes:
> Andy Wingo <wingo@pobox.com> skribis:
>
>> 4) Our fluids currently have problems with threads: if a thread not
>> spawned by a Guile thread enters Guile, its fluids are bound to
>> #f. This should be fixed; in the meantime though we hack around
>> that with the (or ...) clause, which is not a hack that will work
>> for parameters (though perhaps it would, with a wrapper
>> procedure).
>
> Does your parameter proposal intend to address this? (My understanding
> is “no.”)
Indeed, no. I think we need to fix fluids.
>> (define <parameter>
>> ;; Three fields: the procedure itself, the fluid, and the converter.
>> (make-struct <applicable-struct-vtable> 0 'pwprpr))
>> (set-struct-vtable-name! <parameter> '<parameter>)
>>
>> (define (parameter? x) (and (struct? x) (eq? (struct-vtable x) <parameter>)))
>> (define (parameter-fluid p) (struct-ref p 1))
>> (define (parameter-converter p) (struct-ref p 2))
>
> Maybe we should provide ‘define-applicable-record-type’ in
> (srfi srfi-9 gnu). :-)
Yes! However that doesn't help us in boot-9 :)
> To me it looks like we’re adding a 3rd variation on the theme (well,
> ‘make-mutable-parameter’ already existed, but it’s not meant to be used,
> is it?).
>
> Personally, I’ve typically used the fluids API within Guile, for the
> sake of consistency, and SRFI-39 elsewhere. What does it buy us to use
> our own ‘parameterize’ variants in parts of Guile?
Third time's the charm, as they say... here's the deal. `with-fluids'
is fairly efficient, because its body does not need to be allocated as a
closure, but it doesn't provide you any guarantees about the values
bound to the fluids. Parameter objects are better in that way, because
their converter can check the values. Parameterize is just as short as
with-fluids, but preserves this correctness property, so it's a good
thing.
However parameterize was not as efficient as `with-fluids', because its
body must be a closure. This version fixes that, so perhaps parameters
are the thing now.
Also, (fluid-ref x) is more typing than (x), and the dance needed to
define a fluid, init val, and accessor takes longer than (make-parameter
'foo). So parameters are a win IMO.
>> Then we somehow change the
>> `current-input-port' binding to be a <parameter>
>
> How about exposing the fluids the underlie ‘current-input-port’ &
> co. instead? This would allow the use of ‘with-fluids’ instead of
> fiddling with ‘dynamic-wind’ and the like, while being consistent with
> the rest of Guile.
Would you like users to be able to (fluid-set! %current-input-port
'not-a-port)? Or to (with-fluids ((%current-input-port 'foo)) ...) ?
Probably not. I think that we should be switching to parameters for
user-facing dynamic bindings. Fluids are to dynamic bindings what
variables are to toplevel bindings: useful building blocks, but not
usually what you want to give to the user.
WDYT? :)
Andy
--
http://wingolog.org/
next prev parent reply other threads:[~2011-07-01 8:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <99db88be1896528082d33a77ec4cadbe.squirrel@webmail.kapsi.fi>
2011-03-31 11:11 ` How can I tell guile to shut up? ;) Andy Wingo
2011-06-28 21:52 ` Andy Wingo
2011-06-30 1:24 ` Andreas Rottmann
2011-06-30 9:23 ` Andy Wingo
2011-06-30 21:27 ` Ludovic Courtès
2011-07-01 8:16 ` Andy Wingo [this message]
2011-07-01 13:04 ` Ludovic Courtès
2011-07-01 14:26 ` Andy Wingo
2011-07-04 13:24 ` Ludovic Courtès
2011-07-18 21:57 ` Fluids vs parameters: which API is better? Mark H Weaver
2011-07-19 8:19 ` Andy Wingo
2011-07-24 14:52 ` BT Templeton
2011-07-25 9:24 ` Ludovic Courtès
2011-07-25 14:21 ` Andy Wingo
2011-12-05 17:15 ` How can I tell guile to shut up? ;) Andy Wingo
2011-06-30 21:37 ` Ludovic Courtès
2011-07-01 8:03 ` Andy Wingo
2011-07-01 12:49 ` Ludovic Courtès
[not found] <502390579.3690191.1452334008441.JavaMail.yahoo.ref@mail.yahoo.com>
2016-01-09 10:06 ` Tobias Reithmaier
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=87zkky8lgi.fsf@pobox.com \
--to=wingo@pobox.com \
--cc=guile-devel@gnu.org \
--cc=ludo@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).