-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 07/17/2012 03:38 PM, John Cowan wrote:
> Alaric Snell-Pym scripsit:
>
>> So, don't arguments for not defining EQV? on procedures also extend to
>> not defining CONS on procedures?
>
> No, because even if the procedure you extract from a pair is not the
> procedure you put in it, it will be operationally equivalent.  So as
> long as the only thing that matters about a procedure is its behavior
> when invoked, all is well.  It's when you try to treat the procedure
> as an object with identity ("no entity without identity", says Quine)
> that you get into trouble with the R6RS semantics.  Thus for example
> memq/memv/member cannot find a procedure key in the list reliably, nor
> can you be sure that if you use a procedure as the key in a hashtable
> that you will be able to find that entry when you look for it.
>

Mmmm-hrm, thanks.

Cases where I think that being able to eqv? a closure/procedure is
useful are:

 * In optimisations; higher-order procedures like map might special-case
some common procedures that get passed to it (such as the identity
procedure, perhaps).

 * As sanity checks with higher-order procedures that only expect a
limited set of procedures to be passed to them, perhaps because the
interface betwixt them and the procedure isn't entirely public. To give
a questionable example, I've written a turtle graphics library for
children that tries to declare synonymous ways of saying the same thing,
to avoid penalizing mis-remembered syntax; it accepts (left <angle>) and
(right <angle>), but also defines (turn <direction> <angle>) as
(<direction> <angle>) and I'd love to check the direction is left or
right to avoid a confusing result if the user types (turn write 90).
However, this is something of an abuse of the REPL ;-)

ABS

- --
Alaric Snell-Pym
http://www.snell-pym.org.uk/alaric/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlAFhjgACgkQRgz/WHNxCGq3hgCdH6Y/aNTDZAl9vMh1hXtEDUxa
4e0AnR+uHmWKU68YaBdbrZtuqa2QV29U
=Td47
-----END PGP SIGNATURE-----

_______________________________________________
r6rs-discuss mailing list
r6rs-discuss@lists.r6rs.org
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to