-
Notifications
You must be signed in to change notification settings - Fork 465
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: Make the delab attribute resolve the name #4899
Comments
I think there's an issue with having |
Silently doing nothing is indeed not great design, thanks for raising this. I'm sceptical of I like your third alternative, i.e. a syntax that has the function to delab as an ident of it's own. Maybe |
Ha, jinx'ed with kmill. Good to see that we agree here :-) |
Adds `@[app_delab ident]` as a macro for `@[delab app.ident]`. Resolves the identifier when expanding the macro, saving needing to use fully qualified identifiers with `@[delab]`. Also, unlike `@[delab]`, throws an error if the identifier cannot be resolved. Closes leanprover#4899
Adds `@[app_delab ident]` as a macro for `@[delab app.ident]`. Resolves the identifier when expanding the macro, saving needing to use the fully qualified identifiers that `@[delab]` requires. Also, unlike `@[delab]`, throws an error if the identifier cannot be resolved. Closes #4899
Proposal
This proposal's purpose is to improve user experience when writing delaborators. More specifically, the delaborator attribute currently assumes that the name given as argument matches the name internally generated by the delaborator, which means that no name resolution occurs. Not only this may go against the expectations of a user not acknowledged with the delabotor's internals, but this is currently not documented. The Metaprogramming in Lean 4 book (which, AFAIK, is the only available documentation on this topic) does not explicitly mention this detail, and all the examples happen in the root namespace, so this issue never occurs. Even worse, there is no feedback at all that the name is not resolved: if the user does the wrong thing by expecting the name to be resolved, at no point will a warning or an error appear. Rather, nothing happens, which is poor UX.
The proposal is that the delaborator attribute (ie.
@[delab app.foobar]
) should resolve the name of the constant being delaborated. For instance, in the following situationthe current behavior is to do nothing, not even trigger a warning. Instead, it should resolve the name
foobar
so that the actual delaborator key that is registered isapp.Foo.Bar.foobar
. If the name cannot be resolved in the local namespace, the current behavior is preserved.The following alternatives are also possible to improve the user experience:
delab
property is changed to be consistent with how names are resolved in metaprogramming in general@[delab app.foobar]
would become@[delab app `foobar]
if the user doesn't want the name to be resolved, and@[delab app ``foobar]
if the user wants the name to be resolved.Finally, once this RFC is closed and a decision has been made about whether to implement the proposal (or one of its variants) or not, the documentation should be changed to mention this point.
Community Feedback
Zulip thread.
Impact
Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.
The text was updated successfully, but these errors were encountered: