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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -