Open Kha opened 2 months ago
Is it possible to make it expand to the same as ⟨[...]⟩
instead? I would hope that this happens automatically, assuming Array.mk
(or is it Array.ofList
now?) is implemented efficiently and used in the elaboration of #[...]
literals. Alternatively, this could also be implemented by having #[...]
elaborate to an Array.mk
expression when it detects it is in pattern position. This would also fix the issue that mixing ⟨[...]⟩
and #[...]
patterns in the same pattern match doesn't work.
As long as the compiler is able to avoid the performance cost of the naive implementation here, I think this would solve most of the reasoning issues. It's not clear to me if this will happen without any work though, and just removing array literal patterns without compiler support for the elaborated version could result in a performance regression otherwise.
I don't know how feasible that is, but if at all it would have to happen in the new code generator
I think it would still be better to have #[...]
in pattern position mean ⟨[...]⟩
even if it just does the completely naive thing codegen-wise, and this ends up on the todo list for the new code generator.
(I am willing to write a PR for the pattern elaboration part of this, if accepted.)
Just to clarify, this is for the general match
syntax, correct? Not the match
for Syntax
quotations?
If you use the regex \| [^=]*#\[
you can turn up many more examples of array patterns for the general match
. Metaprograms will do match e.getAppFnArgs
and have patterns such as (``Eq, #[_, lhs, rhs])
.
We added support for
#[...]
patterns early on for syntaxmatch
and didn't have a plan for supporting reasoning about it; we never used it in syntaxmatch
and still don't have a reasoning plan. Because of the complexity of even the current implementation, the most reasonable way to move forward is to deprecate and remove the syntax.A perhaps naive regex '
\| #\[
finds about a dozen uses in core and another dozen in the Mathlib tree: