[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] [r6rs-discuss] redefining eqv?

Earlier today, Peter Kourzanov wrote:
> On Wed, 2010-12-22 at 18:36 -0500, Eli Barzilay wrote:
> > You're confusing (or mixing) a local binding (let ((eqv? ...)) ...)
> > with an implicit mutation (define eqv? ...).  
> Is it?

...an implicit muatation?  Yes.
...so different?  Yes.
...a confusion?  Thats how it seems.

> The way I read R6RS, (define) is supposed to (#1) allocate a new
> location for this new eqv?, (#2) set! the result of the expression
> to it and (#3) mutate the *binding* for eqv? in the environment (or
> splice into parent environment when enclosed by begin). At least,
> that's what it typically does for other variables. I.e.,

That's r5rs w/out any module system.  Not r6rs (in a library).

> And, BTW, 11.3 says that (define) is equivalent to (letrec*). So why
> are these cases so different then?

Because those are internal definitions.

> I guess if R6RS enforced macro-implementation of (case), like
> Haskell's Prelude, the problem would be solved (via syntactic
> closures provided by hygiene & referential transparency of
> syntax-rules).


> Alternatively, if you add lazy evaluation of (case) bodies (or
> simulate that with delimited continuations, whatever), you can also
> solve it by using hygiene & referential transparency of functional
> closures with lexical scope. But that is a different language
> altogether too...

I hope that I'm making a mistake here, but it looks like you're
seriously suggesting something like:

  (let ((old-eqv? eqv?))
    (set! eqv? equal?)
    (let ((r (case ...)))
      (set! eqv? old-eqv?)

as a way to get a customizable `case'.  (I'll avoid expressing an
opinion on such a thing, in case this is a mistake.)

> > > And should we do anything about it? [...]
> > 
> > Depends on how "we" is defined.
> I am interested in this mostly from the user perspective. I don't
> know how many users are hanging around here, but I do hope this set
> is at least as large as the set of implementors...

I'm speaking only as a user, who will need to avoid food 24 hours
prior to any work on code like tha above.

> P.S. And I have no problem in (case) using redefined eqv? as you
>      might probably have guessed. I think implementations should be
>      free to make it (optionally) strict, disallowing rebinding of
>      any standard keyword, maybe with define-immutable-binding.
>      Otherwise there must be a way to shoot yourself in the foot.


Earlier today, Peter Kourzanov wrote:
> Still returning to Scheme, I would like to be also in control
> concerning eqv?, [...] when I don't care about exact semantics and
> using something like _syscall when semantics are at stake.

Yeah, I'm most definitely in a very different "we" -- I always care
about "exact semantics" of any code I write, and I certainly hope that
you do too, if you write any code that runs anything I interact with.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Scheme-reports mailing list