xls icon indicating copy to clipboard operation
xls copied to clipboard

[enhancement][dslx] Struct destructuring similar to Rust

Open cdleary opened this issue 10 months ago • 0 comments

What's hard to do? (limit 100 words)

See https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html#destructuring-structs

It'd be nice to pattern match structs similar to record-style pattern matching in ML family of languages, Rust does it similar to this:

let Point { x, y } = p;

Current best alternative workaround (limit 100 words)

Just access the struct fields out individually, or make a "tuplifier" helper function and destructure into tuple names.

Your view of the "best case XLS enhancement" (limit 100 words)

We could pattern match irrefutably for e.g. let statements and we could pattern match refutably for e.g. match statements, with the same syntax as Rust shown above.

cdleary avatar Mar 27 '24 23:03 cdleary