Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider making special forms subject to function shadowing #128

Open
Mercerenies opened this issue Dec 5, 2022 · 0 comments
Open

Consider making special forms subject to function shadowing #128

Mercerenies opened this issue Dec 5, 2022 · 0 comments

Comments

@Mercerenies
Copy link
Owner

Macros are subject to function shadowing, which means

(flet ((if () 999)) (if))

is well defined and returns 999. That's because if is a macro, not a special form.

Special forms, on the other hand, take precedent over all variables, even those in a narrow scope. So

(flet ((cond () 999)) (cond))

will actually return (), not 999, since the cond special form takes precedent over the local function and returns () (since it's been given no arguments.

Since drawing an arbitrary line between built-in macros and special forms like this is fairly unintuitive, I propose that we allow special forms to be shadowed. This does mean that you can basically monkeypatch your way into an unworkable function scope, by redefining all of the primitives. But I think it's worth it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant