You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generally I like the format of aligning the syntax with Python. Here's a few suggestions to make it more idiomatic.
Function Declaration
Should we define out as the return var or make it predetermined based on parsing the return statement? Python typing doesn't specify the variable name, just the type.
Also, you shouldn't need to specify multiple return type values. For
def funcname(
in1: int16,
in2: float32
) -> (
out1: float32,
out2: int8
):
#Body of the function
This would not happen as you'll only be able to return an array if they're the same type, as that's a limitation in languages like C. So you could simplify to something like
def funcname(
in1: int16,
in2: float32
) -> list[int8]:
#Body of the function
Otherwise the rest looks good.
The text was updated successfully, but these errors were encountered:
I also like to be aligned with python however I specified this because cyanobyte spec only allows to return a variable once in the logic, at the end of the function. If statements are not in the spec for now, and it could be tempting to return different variables based on some logic if they were implemented.
TBH I though they were and thats why I stuck with that.
Maybe a better answer is to force the return statement at the end of the function declaration and leave the def() as pure python.
The spec definition says "variable or variable array", the particularities of the compiled language are another thing. If I implement return statements it doesnt matter then.
return var1
return [var1, var2, var3]
To clarify: This last one can be in a preripheral yaml as a yaml list. If the types od the variables are different the C template should throw an error.
Yeah I can see that there may be some potential for logical errors. Depending on how you want the parser to work, you could add validation in each function. Common text editors are able to perform type inference and will know if the return type doesn't match the function signature. But that may be extra work that is unnecessary.
Generally I like the format of aligning the syntax with Python. Here's a few suggestions to make it more idiomatic.
Function Declaration
Should we define
out
as the return var or make it predetermined based on parsing thereturn
statement? Python typing doesn't specify the variable name, just the type.Also, you shouldn't need to specify multiple return type values. For
This would not happen as you'll only be able to return an array if they're the same type, as that's a limitation in languages like C. So you could simplify to something like
Otherwise the rest looks good.
The text was updated successfully, but these errors were encountered: