[r6rs-discuss] [Formal] (r6rs base) must also export _ and ... at level 1

From: Jed Davis <r6rs>
Date: Thu Jan 25 04:02:13 2007

On Wed, Jan 24, 2007 at 07:38:18AM -0500, AndrevanTonder wrote:
> On Wed, 24 Jan 2007, Abdulaziz Ghuloum wrote:
> >Andre van Tonder wrote:
> >
> >>It is stated on p.25 that (r6rs base) exports syntax-rules and
> >>identifier-syntax at level 1. This is insufficient for writing most
> >>useful macros unless the identifiers ... and _ are also exported for
> >>level 1.
> >
> >Three questions:
> >1. Why would this be necessary?
>
> If they are not exported, how would you propose to handle renaming,
> prefixing, or excepting them in a client library?

After a few passes through the relevant bits of the spec, I think I
finally understand what's going on with <literal>s, and there seem to be
two issues here:

1) If ... and _ are not defined within (r6rs base), then things will
work fine as long as those names aren't shadowed by the client code;
they'll be free both at the point of use and in the definition, and thus
will be equivalent up to free-identifier=? by dint of having the same
name.

However, if ... or _ is bound in the client library for whatever reason,
then there's no way to get them back; there's no binding to rename, no
value (at any phase) to re-bind, and no construct that ends the scope
of a binding[*].

2) But, if the literals are bound in the scope where the macro is
created, *then* they must be exported, or else the macro will be of
limited use (which may be desired in some cases, but not this), because
now the equivalence follows the actual bindings, not the text of the
identifiers.

As a convenient advantage, the literals may now be renamed and so on.

3) Bonus issue: the free-identifier=? behavior seems to suggest
origins in the R5RS world, where the top-level scope is at the top of
everything, and any free identifier might later become bound there.
This strikes me as a little incongruous in R6RS, where the "scope" of
such free identifiers is a sort of imaginary ultra-top-level outside of
all libraries, which contains nothing and shall remain ever so.

Not that I have any better idea.


[*] http://lambda-the-ultimate.org/node/858
-- 
(let ((C call-with-current-continuation)) (apply (lambda (x y) (x y)) (map
((lambda (r) ((C C) (lambda (s) (r (lambda l (apply (s s) l))))))  (lambda
(f) (lambda (l) (if (null? l) C (lambda (k) (display (car l)) ((f (cdr l))
(C k)))))))    '((#\J #\d #\D #\v #\s) (#\e #\space #\a #\i #\newline)))))
Received on Thu Jan 25 2007 - 04:02:09 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC