Why we can define a function with the same name of

2019-09-06 14:15发布

We can define a new function like this:

(define (car x y) (+ x y))

And use car as an add function. Meanwhile, we lost the built-in function car. Why does Racket allow this? How could we recover the lost built-in function, here is car.

1条回答
The star\"
2楼-- · 2019-09-06 14:24

Definitions affect the current module only (and, if you export your definition, then any other modules that import your module). You can always import Racket's built-in functions under a different name, if you want to use car in your module for something else. For example:

(require (only-in racket/base (car racket-car)))

Now, you can use racket-car to refer to the built-in car function.

查看更多
登录 后发表回答