google / xls

XLS: Accelerated HW Synthesis

Home Page:http://google.github.io/xls/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[enhancement][dslx] Struct destructuring similar to Rust

cdleary opened this issue · 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.