[R6RS] safe and unsafe; declarations
dyb at cs.indiana.edu
dyb at cs.indiana.edu
Sat Mar 4 13:08:29 EST 2006
> > If we agree to this proposal, then I also intend to suggest that an
> > identifier-priority procedure be included in the standard syntax-case
> > system. This procedure can be used to extract a priority associated with
> > an identifier, e.g.:
> > (define-syntax frobitate
> > (lambda (x)
> > (syntax-case x ()
> > [(k (x ...) e)
> > (if (= (identifier-priority 'safe #'k) 0)
> > #'<unsafe code>
> > #'<safe code>)])))
> > This will allow user-defined syntactic forms to be sensitive to declared
> > priorities. In conjunction with identifier macros, it will also allow a
> > similar effect for user-defined procedures.
> That is a feeping creature. It will *not* allow user-defined
> syntactic forms to be sensitive to declared priorities unless
> we also require implementations to notice declarations, which
> I would oppose.
One editor's feeping creature is another editor's way of giving a model
for how built-in libraries might work and providing similar ability to
the developers of user-defined libraries. Each to his own. As I said,
I intend to suggest it. If no one else likes it, so be it.
You're right that it doesn't allow user-defined syntactic forms to
be sensitive to declared priorities. That was a misstatement, since
we've already said that declarations can be ignored. What it does do,
however, is allow them to be sensitive to the priorities in place.
If an implementation ignores declarations, the priorities returned by
identifier-priority will simply be the implementation defaults.
> Furthermore it would introduce a way for
> programmers to make their code arbitrarily sensitive to all
> priorities, not just the safe priority.
Right. That's the idea.
> The programmer of
> some random library module could use Kent's proposed feature
> to make a (fast 3) declaration in some client module behave
> like an unsafe declaration.
The programmer can make the library unsafe anyway, even without
identifier-priority. With identifier-priority they have no excuse,
since they have a way to determine whether doing so is okay.
It's better to allow libraries to make informed decisions about safety,
speed, etc., at expand time when the alternative is to hard-wire such
> I don't mind if Kent wants to add that kind of dangerous hair
> to Chez Scheme's implementation of syntax-case, but we shouldn't
> require every implementation to do this on behalf of the few
> programs and systems that will use or implement an unsafe mode.
There's no danger inherent in making the information available, and it's
actually more likely to encourage library developers to operate in a safe
mode unless the safe priority gives them permission to do otherwise. It's
not very hairy either. In particular, defining implementation-priority is
trivial if an implementation chooses not to process declarations. Also,
as you pointed out, it's not just for unsafe mode, so it's on behalf of
the programs and systems that will use or implement any of the modes.
More information about the R6RS