scheme - If I shadow a buit-in function, how can I recover it? -
take example:
(define sqrt (lambda (x) (* 2 (sqrt x)))) (sqrt 2) 2.828427 ...
how can call original built-in sqrt
procedure without restarting interpreter (or undefine shadowing define)?
actually, happens internally when this? built-in overwritten, or 2 procedures coexist in different namespaces?
your definition of sqrt
cause stack overflow, because recurses itself, not built-in sqrt
. :-p
anyway, in racket, definition of sqrt
affect current module only. possible reimport built-in sqrt
under different name, , call module-specific sqrt
:
(require (rename-in racket/base [sqrt racket-sqrt])) (define sqrt (lambda (x) (* 2 (racket-sqrt x))))
note code won't affect other modules don't import module's sqrt
definition; continue use built-in sqrt
.
Comments
Post a Comment