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

Re: [Scheme-reports] Seeking review of sets and hash tables proposals



Taylan Ulrich B. scripsit:

> > ;; Somewhere along the line, ‘eqv?’ changes …
> > (define eqv? (lambda (a b) (not (equal? a b))))
> > ;; … but noone told me!
> > (define quaz (set eqv? 0 1 2))
> > (set=? foo quaz) => #f ; expecting #t
> > (display quaz) => ?? ; unspecified, expecting #setv(0 1 2)

Quite right, certainly at the REPL.  In a library, this can't happen,
because it's an error to mutate an imported identifier.

> I fail to understand the problem in the example.  Should the programmer
> not be always aware of any re-binding of `eqv?', regardless of what its
> default binding happens to be?  Indeed, the specification could say that
> #setv sets use "the procedure bound to the identifier `eqv?' in the
> default environment" or so, or it could just spell out the semantics of
> eqv?  without mentioning the identifier `eqv?', etc., but in no case
> should it actually depend on that identifier's binding at any time.

That's an open question.  In general, lexical syntax may or may not
be hygienic.  #(...) is, in the sense that if you interpret #(foo bar)
unofficially as (vector 'foo 'bar), this uses the binding of `vector`
in the base library.  On the other hand, ' is not hygienic at all:
(let ((quote -)) '32) evaluates to -32, not 32, and this is true even
in hygiene-fanatical Racket.

> Indeed, looking at draft 9, I see it refer to "eqv?" in the definition
> of `case'.  That seems to be an analogous case to this one; no mention
> of an "identifier" is made, and in my opinion it's relatively clear that
> the intended meaning is the procedure known as "eqv?" regardless of what
> identifier it's bound to at any time, and regardless of any binding for
> the identifier `eqv?' at any time.

There's no possible ambiguity there:  `case` is a hygienic macro, and
so it uses the definition of `eqv?` bound in the base library, where
`case` itself is bound.

-- 
John Cowan  cowan@x  http://www.ccil.org/~cowan
Does anybody want any flotsam? / I've gotsam.
Does anybody want any jetsam? / I can getsam.
        --Ogden Nash, No Doctors Today, Thank You

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports