yaegi
yaegi copied to clipboard
interp: default to None for non-valued statements
Here am using 'None' to refer to the functional programming concept of an empty result. I added interp.EmptyResult
since that is far clearer than 'None', especially to users not familiar with functional programming jargon.
Updates *Interpreter.ast
to use val: EmptyResult
as the default, instead of new(interface{})
. Updates genValue
to always return node.val
for a block statement where the last statement is var x = 1
, x := 1
, or x = 1
.
As a result, variable declarations and assignments return a value of interp.EmptyResult
.
The current state is not consistent. It would be better to always disable result output for assignment rather than adding an option, for consistency and simplicity. Could you modify your PR in that direction ? Thanks
@mvertes This is ready for review. Now, all variable declarations and assignments return the special value interp.EmptyResult
.