The viper code emitter
Posted: Sun Jul 12, 2015 8:24 am
What is the development status of this? Can it be considered stable? Are the rules for writing viper code documented? I have some code which runs normally and with the native emitter but I'm struggling with compile time errors under viper.
Firstly functions seem to be able to return strings or None, but if I try to return an integer I get "ViperTypeError: return expected 'object' but got 'int'". Secondly, to avoid compile time errors it seems necessary to cast function arguments to integers to perform bitwise operations on them (even though at runtime they would be passed as integers). This example yields at compile time "ViperTypeError: can't do binary op between 'object' and 'int'" .:
Lastly viper compile time errors don't provide a line number which makes finding them rather challenging.
Firstly functions seem to be able to return strings or None, but if I try to return an integer I get "ViperTypeError: return expected 'object' but got 'int'". Secondly, to avoid compile time errors it seems necessary to cast function arguments to integers to perform bitwise operations on them (even though at runtime they would be passed as integers). This example yields at compile time "ViperTypeError: can't do binary op between 'object' and 'int'" .:
Code: Select all
@micropython.viper
def foo(num):
num <<= 1
return "4" if num == 4 else "not four"