-
Notifications
You must be signed in to change notification settings - Fork 32
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
[CEP] Proposal for libobject API refactoring #65
base: master
Are you sure you want to change the base?
Conversation
categories, names, locations. For now we implement a reverse map for | ||
names, but more options could be desirable after more experimentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this refer to a branch somewhere or is more like "for now we propose to start with a reverse map for names"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is implemented in the prototype branch, cleaning it up to submit as we speak.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR done, you can use (hack hack) Print Graph
to print the reverse map
|
||
In particular, we can distinguish a few common behaviors: | ||
|
||
- `Kernel` : objects with this trait provide a function to register with a `safe_env` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that currently I believe the only part of libobject which modifies the safe_env is the Require replay after closing section/module (in_require in library.ml).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, that's correct. Tho the trait is meant to capture objects that call the diverse Global.*
functions, so at some point the env can be owned by declaremods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've clarified this a bit in an update.
In particular, we can distinguish a few common behaviors: | ||
|
||
- `Kernel` : objects with this trait provide a function to register with a `safe_env` | ||
- `Named` : objects with this trait can register with the `Nametab`, in a uniform way |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that currently nametab itself is not uniform (there are separate tables for globref, modules, ltacs, some other stuff) so this may require a nametab redesign first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FTR I think that unifying the various nametabs is gong the wrong way. It's a feature that each plugin can define its own set of names, so the design critically needs to account for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the idea is that when an object declares a nametab trait, it does so with their own nametab. Refactoring is indeed needed, you can see current progress here, but need to advance more https://github.com/ejgallego/coq/blob/f059e5a57e95c5c80a3c9026e91ba91936d90db5/library/nametab.mli
Ideally, if we think this is a good idea we would do such a change in two steps:
- we would first define the trait, which takes a module as a parameter and performs the imperative state
- we would then push the trait to be functional, and have
Declaremods
own the nametab.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarified a bit.
0b6ff3d
to
3b2d4e2
Compare
Can you explain how the proposed approach solves/improves-on the downsides of the current approach, in particular:
|
For this see for example coq/coq#16261 , and how the API with the reverse map introduced here is used in Search and Locate. If we move
Hopefully the Named trait could be used to avoid the global state update for the Nametab in |
# Part II: behavior specification | ||
|
||
The second part of this CEP, not yet implemented, is to phase out the | ||
`declare_object` API in favor a set of `Behavior.t` traits that an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a description of the Behavior
API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a too precise view on how to implement it, there are several options so here we can use some feedback.
I guess for the first prototype I'd try to have a list of traits, indeed due to the existential nature of traits that would mean turning the declaration of objects into a module, but I think I'm fine with that (as in the case for the proposal about errors in coq/coq#12602)
3b2d4e2
to
3574f2d
Compare
This is both a cleanup and a step towards pushing the state upwards, and handling the nametabs functionally. Related to coq#16746 and coq/ceps#65
This is both a cleanup and a step towards pushing the state upwards, and handling the nametabs functionally. Related to coq#16746 and coq/ceps#65
This is both a cleanup and a step towards pushing the state upwards, and handling the nametabs functionally. Related to coq#16746 and coq/ceps#65
This is both a cleanup and a step towards pushing the state upwards, and handling the nametabs functionally. Related to coq#16746 and coq/ceps#65
This is both a cleanup and a step towards pushing the state upwards, and handling the nametabs functionally. Related to coq#16746 and coq/ceps#65
This is both a cleanup and a step towards pushing the state upwards, and handling the nametabs functionally. Related to coq#16746 and coq/ceps#65
This is both a cleanup and a step towards pushing the state upwards, and handling the nametabs functionally. Related to coq#16746 and coq/ceps#65
This is a first implementation of CEP coq/ceps#65 We add a common metadata object to atomic libobjects, so we can store documentation, location, names, and other interesting attributes that are needed by clients to implement functionality. As we allow storing names of the objects, we can index them by name to provide efficient reverse lookup. We export an experimental API for clients to consume this metadata. PR coq#16261 is implemented on top of this one.
This is a first implementation of CEP coq/ceps#65 We add a common metadata object to atomic libobjects, so we can store documentation, location, names, and other interesting attributes that are needed by clients to implement functionality. As we allow storing names of the objects, we can index them by name to provide efficient reverse lookup. We export an experimental API for clients to consume this metadata. PR coq#16261 is implemented on top of this one.
This is a first implementation of CEP coq/ceps#65 We add a common metadata object to atomic libobjects, so we can store documentation, location, names, and other interesting attributes that are needed by clients to implement functionality. As we allow storing names of the objects, we can index them by name to provide efficient reverse lookup. We export an experimental API for clients to consume this metadata. PR coq#16261 is implemented on top of this one.
This is a first implementation of CEP coq/ceps#65 We add a common metadata object to atomic libobjects, so we can store documentation, location, names, and other interesting attributes that are needed by clients to implement functionality. As we allow storing names of the objects, we can index them by name to provide efficient reverse lookup. We export an experimental API for clients to consume this metadata. PR coq#16261 is implemented on top of this one.
This is both a cleanup and a step towards pushing the state upwards, and handling the nametabs functionally. Related to coq#16746 and coq/ceps#65
This is both a cleanup and a step towards pushing the state upwards, and handling the nametabs functionally. Related to coq#16746 and coq/ceps#65
This is both a cleanup and a step towards pushing the state upwards, and handling the nametabs functionally. Related to coq#16746 and coq/ceps#65
This is both a cleanup and a step towards pushing the state upwards, and handling the nametabs functionally. Related to coq#16746 and coq/ceps#65
Rendered version here