[r6rs-discuss] comment and vote (re-definition)
On Fri, 24 Aug 2007, Keith Wright wrote:
> If this interpretation is correct, then the above definition
> of |sqrt| is legal in a <body>, even if that <body> imports
> the standard definition of |sqrt|.
With one caveat. Section 7.1 says:
... no identifier can be imported multiple times, defined
multiple times, or both defined and imported.
So yes, you can import the binding of standard sqrt into a
library that defines its own sqrt if you rename the former
on import like this:
(library (foo)
(export ---)
(import (rename (rnrs) (sqrt rnrs:sqrt)))
(define (sqrt x) ---)
---)
The advantage of this over r5rs toplevel redefinitions is of
course that other libraries that rely on the standard sqrt will
not be broken by the local definition of sqrt in (foo).
In this respect library definitions scope just like the
internal definitions Scheme has had for a long time.
By the way, this also resolves an inconsistency in R5RS where
toplevel redefinitions would affect user-defined procedures
but were required not to affect standard procedures.
Andre
Received on Fri Aug 24 2007 - 23:23:45 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:01 UTC