Control Flow - Circom 2 Documentation
If the initialization_code includes a var declaration then its scope is reduced to the for statement and hence, using it later on (without defining it again) will produce a compilation error. while ( boolean_condition ) block_of_code It executes the block of code while the condition holds. The condition is checked every time before executing the block of code. Important: when constraints are generated in any block inside an if-then-else or loop statement, the condition cannot be unknown (see Unknowns). This is because the constraint generation must be unique and cannot depend on unknown input signals. In case the expression in the condition is unknown and some constraint is generated, the compiler will generate the next error message: "There are constraints depending on the value of the condition and it can be unknown during the constraint generation phase". In this example, the condition depends on the input signal in whose value is unknown at compilation time. Let us also notice that
Control Flow We have standard constructions for defining the control flow of the program. Conditional statement: if-then-else if ( boolean_condition ) block_of_code else block_of_code The else part is optional. When omitted, it means "else do nothing". var x = 0; var y = 1; if (x >= 0) { x = y + 1; y += 1; } else { y = x; } Loop statement: for for ( initialization_code ; boolean_condition ; step_code ) block_of_code If the initialization_code includes a var declaration then its scope is reduced to the for statement and hence, using it later on (without defining it again) will produce a compila
Explore this link on the map →related reading
- Scoping - Circom 2 Documentationdocs.circom.io
- Control Flow - The Rust Programming Languagedoc.rust-lang.org
- Jumping Back and Forth · Crafting Interpreterscraftinginterpreters.com
- Control Flow · Crafting Interpreterscraftinginterpreters.com
- Control Flow - The Rust Programming Languagerust-book.cs.brown.edu
- Decide with ifeducative.io
- Notes on structured concurrency, or: Go statement considered harmful - njs blogvorpus.org
- CSC 151 - Conditional evaluation in Schemeeikmeier.sites.grinnell.edu
- Templates & Components - Circom 2 Documentationdocs.circom.io
- Writing a C compiler in 500 lines of Pythonvgel.me
- A Gentle Introduction to LLVM IR · mcyoungmcyoung.xyz
- The match Control Flow Construct - The Rust Programming Languagedoc.rust-lang.org