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

User attributes #513

Closed
leodemoura opened this issue Jun 6, 2021 · 2 comments
Closed

User attributes #513

leodemoura opened this issue Jun 6, 2021 · 2 comments
Labels
feature missing feature

Comments

@leodemoura
Copy link
Member

leodemoura commented Jun 6, 2021

We should allow users to declare their own attributes. This feature is supported in Lean 3 and is used in a few mathlib metaprograms.

@leodemoura leodemoura changed the title User attributer User attributes Jun 6, 2021
@leodemoura leodemoura added the feature missing feature label Jun 6, 2021
@Kha
Copy link
Member

Kha commented Jun 6, 2021

Just to explain the current state: attributes can be registered only in builtin_initialize, i.e. initializers compiled into native code. However, this is not a good idea to do in plugins (i.e. anywhere outside the stdlib) because environment extensions (what attributes boil down to) are identified by an index assumed to be globally unique. Thus .olean files will not be compatible between packages using different sequences of attribute-declaring plugins, and in particular you will not be able to depend on two independent packages declaring (and using) attributes. If I'm not mistaken.

@tydeu
Copy link
Member

tydeu commented Jun 11, 2021

Looking through the environment code, I noticed that the globally unique index @Kha mentioned is an incrementing Nat that is simply the extension's index in the array of extensions. Could one way of solving at least the order problem @Kha presented be to use a Name instead to index the extensions? This would at least allow users to safely use plugins to register new attributes (until proper non-builtin attributes arrive).

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

No branches or pull requests

3 participants