HVM icon indicating copy to clipboard operation
HVM copied to clipboard

Add HVM.seq and `seq` syntax.

Open FranchuFranchu opened this issue 2 years ago • 1 comments

This PR adds a seq syntax, similar to ٰask and let, to allow for sequential computation in HVM. It is useful for working with global variables. It is syntax sugar for a new precomp function HVM.seq, which can be implemented in pure HVM code but I've decided to make it builtin.

I've also added examples in the examples directory.

Example usage:

SideEffectful = (HVM.log "Banana" 0)

Main = 
        // Usecase one: Running functions with side-effects where you discard the value
        seq SideEffectful;
	// Usecase two: Working with global variables.
	let some_val = (@$value(20) 10)
	seq twenty = some_val;
	seq (HVM.log $value 0);
	twenty

FranchuFranchu avatar Apr 03 '23 21:04 FranchuFranchu

Thank you so much Franchu! I've left some comments on the code.

VictorTaelin avatar Apr 05 '23 11:04 VictorTaelin