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

Constructing Extensions with ExtensionRegistries is difficult #676

Closed
acl-cqc opened this issue Nov 10, 2023 · 0 comments · Fixed by #701
Closed

Constructing Extensions with ExtensionRegistries is difficult #676

acl-cqc opened this issue Nov 10, 2023 · 0 comments · Fixed by #701
Assignees

Comments

@acl-cqc
Copy link
Contributor

acl-cqc commented Nov 10, 2023

Extension::add_op_.... takes an ExtensionRegistry which it uses to validate the type params, type scheme etc. of the new op. But if the op refers to types defined in the same extension, this is very tricky!!

One possible but far-from-ideal situation is to break every extension into two - the types and the ops - then you can build an ExtensionRegistry from the types before starting on the ops.

Another possibility would be for add_op_xxx to include the extension (to which the op is added) together in the ExtensionRegistry when validating the type scheme. That allows an Extension's ops to refer to types in the same Extension, but is still difficult if you are making two Extensions each of which has ops referring to the others types, say.

Instead we propose a solution where adding an op, etc., does not perform validation or require an ExtensionRegistry (?). Instead validation of the whole ExtensionRegistry is performed in a single step (when building the ExtensionRegistry out of a Vec, say). Feedback is a little slower but this recovers most flexibility.

github-merge-queue bot pushed a commit that referenced this issue Nov 13, 2023
…#678)

Closes #658 

As a drive by improve extensions test coverage as I went.

Definition can be a bit unintuitive, should improve after #676 is done.
@acl-cqc acl-cqc self-assigned this Nov 16, 2023
github-merge-queue bot pushed a commit that referenced this issue Nov 20, 2023
…701)

Closes #676 
* Replace PolyFunc::new_validated with ::new to allow (a) building
without an ExtensionRegistry and (b) PolyFuncTypes with free variables
(necessary for nested instances)
* Update a bunch of code in std_extensions code and elsewhere using a
`temp_reg` or similar, this is no longer needed
* Change `[Extension1, Extension2, ...].into()` into
`ExtensionRegistry::try_new` which does validation and can fail with an
`(ExtensionId, SignatureError)`
* This required updating the test_quantum extension's registry to
include float_types
* Some commoning up of registries, and move `test_registry` to the one
file that actually used it (it doesn't seem so distinguished now we have
registries all over the place!)
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

Successfully merging a pull request may close this issue.

1 participant