[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Scheme-reports] [r6rs-discuss] Procedure equivalence: the last debate
- To: John Cowan <cowan@x>
- Subject: Re: [Scheme-reports] [r6rs-discuss] Procedure equivalence: the last debate
- From: will@x
- Date: Wed, 5 Jun 2013 18:47:55 -0400 (EDT)
- Cc: r6rs-discuss@x, scheme-reports@x
- In-reply-to: <26510033.2321161370472452989.JavaMail.root@zimbra>
[Warning: sent to both r6rs-discuss and scheme-reports]
John Cowan wrote:
> The following code fragment is not portable:
> (let ((equiv? (hashtable-equivalence-function some-hash-table)))
> ((eqv? equiv? eq?)
> ((eqv? equiv? eqv?)
> (make-hashtable equiv?))))
> Code like this actually appears in the R6RS implementation of SRFI 69 at
> which suggests that in fact none of the R6RS implementations are making
> use of this optimization, at least in this kind of case.
I doubt whether that code really needs to be completely portable.
The web site cited mentions only three implementations of Scheme
in which the code is alleged to work, along with one more that's
"semi-supported". It seems to me that it's okay for code to rely
on non-portable peculiarities of the small finite number of
implementations it claims to support.
The original reference implementation of SRFI 69 was non-portable
even with respect to R5RS semantics. The purpose of that reference
implementation was to provide a good starting point that could be
tailored/rewritten to take advantage of implementation-specific
features and characteristics.
Although the R6RS allows both eq? and eqv? to return #f whenever
either argument is a procedure, most implementations of the R6RS
provide implementations of eq? and eqv? that are more useful than
required by the R6RS. When writing portable R6RS code, however,
passing procedures to eq? or eqv? is pretty much limited to caching
and other situations where detecting equivalence of procedures is
helpful but not absolutely essential.
That's one of the reasons I favor changing the R7RS small-language
document to make the semantics of eq? and eqv? somewhat closer to the
R5RS semantics than to the R6RS semantics. Another reason for making
this change is the R6RS requirement that eq? and eqv? behave the
same on procedures, which was *not* required by the R5RS. That new
requirement has had the practical effect of forbidding the compiler
optimizations the R6RS semantics was intended to allow (according
to R6RS rationale section 11.5.1).
Scheme-reports mailing list