[r6rs-discuss] [Formal] eliminate library export immutability
Andre van Tonder
andre at het.brown.edu
Tue Mar 20 12:56:29 EDT 2007
On Tue, 20 Mar 2007, Andre van Tonder wrote:
> On Tue, 20 Mar 2007, Abdulaziz Ghuloum wrote:
>> On Mar 19, 2007, at 11:42 AM, AndrevanTonder wrote:
>>> Doesn't the example violate the LETREC* restriction, though?
>>> One restriction on letrec* is very important: it must be possible to
>>> each <init> without assigning or referring to the value the
>>> <variable> or the <variable> of any of the bindings that follow it in
>>> In particular, the second time the RHS of the (define x ....) binding is
>>> evaluated, you are actually referring (via the (cadr x) in set-y!) to
>>> value of x itself. So the example may already be illegal.
>> The program does not violate the letrec* restriction since in the second
>> the value of x has already been determined (the first time around). The
>> never refers or assigns to any uninitialized bindings.
> That is not what the letrec* restriction says. The letrec* restriction
> quoted above says nothing about whether the binding is uninitialized. The
> <undefined> implementation strategy is mentioned only later, where it is
> called approximate.
In fact, the letrec* restriction can be read to imply that the
following expression, using /internal/ definition, is also invalid:
(define x (call/cc (lambda (k) k)))
(unless (number? x)
since the second evaluation of the RHS of the definition is
needs a preceding reference to x to proceed.
I would actually support outlawing mutiple returns to
all definitions, including internal definitions, for the
- I suspect that it may make certain optimizations
(such as detecting possibilities for inlining or direct
substitution) more difficult. It is no longer sufficient
to detect set! statements to determine mutability.
Mutability detection becomes undecidable.
- Overloading the meaning of DEFINE to effect mutations
is unnecessary and just feels like an abuse to me.
The intention of mutation does not get clearly expressed.
I think it would be better if programmers were required to
express all mutations using set!. In other words, I think
programmers should be required to write the above as
(set! x (call/cc (lambda (k) k))))
(unless (number? x)
More information about the r6rs-discuss