-
Notifications
You must be signed in to change notification settings - Fork 463
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
RFC: optionally disable automatic namespace based on prefix #6855
Comments
|
I didn't know. Is it documented somewhere? |
The way I see it, namespace List
def uppercaseLetters ... This flag would break that correspondence, and so would make the language less consistent. |
It should be viewed the other way around. Opening namespaces should not be the default way to write code. |
As a matter of fact, I wouldn't mind at all if the same flag simultaneously forbade the syntaxes |
Note that you can avoid opening namespaces (for instance, I don't open them at all, as I find them confusing). I believe we should similarly have a choice to opt-out of this namespace-like behavior. |
Thanks for writing up a comprehensive RFC. We looked at it again in the triage team meeting and reached consensus on my initial suspicion in #6436 (comment) that this kind of language semantics should not be toggleable with an option. If you feel strongly about disallowing a core syntax in your own projects, the best solution is to write a custom linter. |
I would like to have a project-wide setting to disable automatic opening of a namespace for the declaration's name prefix.
Consider the following definition:
The above is a nice syntax and I want it to stay allowed.
The next definition is less nice but also acceptable:
And here comes what I would like to change; the following definition compiles but I would like it to be (with the aforementioned project-wide setting) a syntax error instead:
Note that it is a fragile style of programming. The following code does not compile:
I would rather want (with the aforementioned project-wide setting) both
List.uppcaseLetters
andLiszt.uppcaseLetters
to be parsed the same way (here, giving a syntax error).Similarly, I would like every
theorem
to be parsed the same way as if it wasexample
instead, including its proof.In the example above, with the new settings, I would be forced to write
List.map (g ∘ f) l
orl.map (g ∘ f)
becausemap (g ∘ f) l
would cause a syntax error.Currently
map (g ∘ f) l
is allowed, which is what I would like to change (optionally, for the entire project).With the setting I suggested, it would be easier to maintain a project so that its code stays readable.
Reading
l.map (g ∘ f)
makes it immediately clear what function is called.Reading
map (g ∘ f) l
does not make it immediately clear what function is called.Reading
List.map (g ∘ f) l
is not problematic.It can be argued that
map (g ∘ f) l
should be rejected by a custom linter rather than by a custom Lean setting.However, such a change is not only a matter of style.
The status quo can have real negative consequences!
Here, the letter
a
is printed:Here, after changing only the spelling of the last definition, the letter
b
is printed:I conclude that the suggested new setting would both;
User Experience would not change for the users who keep the default project settings.
User Experience would improve for users who change the project settings, assuming they have similar preferences as I outlined above.
Maintainability would worsen for the Lean 4 repository, as it would be an additional setting that would need to be maintained.
Maintainability would improve for project written in Lean 4, because a name change would not change the statement of a theorem or what a function does.
Discussion:
https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Disable.20automatic.20namespace
The text was updated successfully, but these errors were encountered: