From: Andy Wingo <wingo@pobox.com>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-devel@gnu.org
Subject: Re: Fluids vs parameters: which API is better?
Date: Mon, 25 Jul 2011 16:21:45 +0200 [thread overview]
Message-ID: <87k4b6zbie.fsf@pobox.com> (raw)
In-Reply-To: <87vcuq67cg.fsf@gnu.org> ("Ludovic Courtès"'s message of "Mon, 25 Jul 2011 11:24:31 +0200")
Hello!
On Mon 25 Jul 2011 11:24, ludo@gnu.org (Ludovic Courtès) writes:
> BT Templeton <bpt@hcoop.net> skribis:
>
>> Andy Wingo <wingo@pobox.com> writes:
>
> [...]
>
>>> Here I disagree. From the perspective of semantics and security, it's
>>> important to be able to make assertions as to the type of value returned
>>> by a procedure -- that (current-input-port) returns a port. The same
>>> goes for (current-language) and all the other dynamic parameters.
>>> Parameters allow us to make guarantees like that.
>>
>> Why is it uniquely useful to be able to make these guarantees for
>> dynamically-bound values? Static/soft typing would be more generally
>> useful than parameters.
>
> I agree it’s not specific to dynamically-bound values.
>
> Andy mentioned that exporting, say, the fluid that underlies
> ‘current-output-port’ would be a problem because you could ‘fluid-set!’
> it to anything, which would lead to an obscure wrong-type-arg error
> sometime.
>
> OTOH it could be argued that this is no different with mutable global
> variables.
FWIW I think it's fine to export the fluid corresponding to
current-output-port -- and indeed the `parameter-fluid' accessor would
allow you to get at these values. But, if you would like to provide a
minimal environment for untrusted code, you wouldn't provide
parameter-fluid (or struct-ref) to that code.
In Guile we have a tension between providing both hackability and
reliability. We have many ways of resolving this tension -- modules,
convention, and tools among them. In this case I would use all three --
expose the fluids you need to, but only if you need to; by convention,
avoid direct fluid access to other modules' fluids; and such access
should cause compile-time warnings (to give feedback to the user about
our conventions).
We should do the same for global variables, btw. Set! to a variable
exported by another module should produce a warning.
As you mention BT, typing (and contracts) can help too. We don't have
them currently, but that's no reason to eschew the tools that we do
have.
>> Also, I'd prefer it if parameters used a type predicate or a type
>> specifier object instead of a conversion procedure. ISTM that the
>> current interface conflates type checking and coercion.
>
> Well, Andy’s proposal is similar to SRFI-39 and I find it convenient
> this way.
In addition, this step does not preclude type specifier objects, were
Guile to get them at some point. They can be defined as wrappers to
`make-parameter' et al. Racket is really leading the way here, I
think; do read Findler's contracts work if you have an interest in such
things.
Andy
--
http://wingolog.org/
next prev parent reply other threads:[~2011-07-25 14:21 UTC|newest]
Thread overview: 18+ 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
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 [this message]
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
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=87k4b6zbie.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).