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

check for duplicate definitions #3

Open
shriram opened this issue Sep 18, 2019 · 4 comments
Open

check for duplicate definitions #3

shriram opened this issue Sep 18, 2019 · 4 comments

Comments

@shriram
Copy link
Owner

shriram commented Sep 18, 2019

defvar and deffun should probably check for and reject duplicate definitions in some meaningful way. (Though what exactly is a "duplicate" definition? Perhaps we need a list of prior top-level definitions? What about inside nested scopes?)

@LuKuangChen
Copy link
Collaborator

dyn-scope-is-bad must have this issue. Are you also referring to other #langs?

@shriram
Copy link
Owner Author

shriram commented Oct 9, 2021

Yes, in general, because otherwise people try to use this "feature" to create weird programs that are not actually interesting SMoL programs (this is an artifact of the Scheme/Racket definitions window semantics, not of the standard model).

My ultimate goal here is to keep students focused on SMoL, and not get distracted by Racket-permitted artifacts. The excessively lightweight embedding into Racket means Racket percolates too much, and needs to be blocked more.

@LuKuangChen
Copy link
Collaborator

LuKuangChen commented Oct 17, 2021

I understand that you want to keep students focused on SMoL. But I can't see how Racket differs from other SMoL languages. AFAIK, Python, Java, and OCaml all allow shadowing, same in #lang smol. Both Java and OCaml disallow declaring one identifier as two variables at the same scope level, also same in #lang smol. (Python is a bit special because it merges the syntax of definition and mutation.)

@shriram
Copy link
Owner Author

shriram commented Oct 23, 2021

The problem is that the "top-level scope" is screwed up in so many languages. I don't even think there is a "standard model" — each one is messed up somewhat differently. (And it gets even more complicated when you get to the REPL.)

Given that there is no SMoL for this, I would rather we have a simple and easy-to-understand semantics. That both avoids picking one non-trivial solution out of many solutions where none is standard, AND keeps students from getting caught up in knots.

It seems to me that rejecting programs with duplicate definitions might be the simplest of those solutions.

But if you want to argue for a different semantics, go ahead!

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

2 participants