Open mikex-oss opened 2 weeks ago
Unlike Rust (or even Python), DSLX requires functions to be defined above first use.
Borrowing from https://doc.rust-lang.org/book/ch03-03-how-functions-work.html, this does not work:
fn main() -> () { trace_fmt!("Hello, world!"); another_function(); } fn another_function() { trace_fmt!("Another function."); }
0001: fn main() -> () { 0002: trace_fmt!("Hello, world!"); 0003: another_function(); ~~~~~~~~~~^--------------^ ParseError: Cannot find a definition for name: "another_function"
This should work as long as another_function is defined in some scope visible to the body of main.
another_function
main
You must define the functions in order:
fn another_function() { trace_fmt!("Another function."); } fn main() -> () { trace_fmt!("Hello, world!"); another_function(); }
Seems we need a first pass to collect the functions defined in scope.
related/dup of https://github.com/google/xls/issues/197 ?
Duplicate of #197
What's hard to do? (limit 100 words)
Unlike Rust (or even Python), DSLX requires functions to be defined above first use.
Borrowing from https://doc.rust-lang.org/book/ch03-03-how-functions-work.html, this does not work:
This should work as long as
another_function
is defined in some scope visible to the body ofmain
.Current best alternative workaround (limit 100 words)
You must define the functions in order:
Your view of the "best case XLS enhancement" (limit 100 words)
Seems we need a first pass to collect the functions defined in scope.