ZoKrates
ZoKrates copied to clipboard
Interpret multi-line function parameters / array assignments
Hi team! This is probably a low priority 'nice-to-have' feature...
Currently, multi-line comma-separated 'lists' aren't supported.
Examples of 'comma separated lists' (I can't think of a better term for these):
struct MyStruct {
field key1
field key2
field key3
}
def myFunction(field a, field b, field c) -> (field):
field[3] myArray = [a, b, c]
field d = otherFunction(a, b, c)
MyStruct myStruct = MyStruct { key1: a, key2: b, key3: c }
Sometimes, especially working with long variable names, or accessing structs, these 'lists' can spill onto many lines and be difficult to read.
Would it be possible to allow multi-line lists? E.g.:
def myFunction(
field a,
field b,
field c
) -> (field):
field[3] myArray = [
a,
b,
c
]
field d = otherFunction(
a,
b,
c
)
MyStruct myStruct = MyStruct {
key1: a,
key2: b,
key3: c
}
Hey @iAmMichaelConnor, this should work today:
def main(\
field a,\
field b,\
field c\
) -> (field):
field[3] myArray = [\
a,\
b,\
c\
]
field d = otherFunction(\
a,\
b,\
c\
)
MyStruct myStruct = MyStruct {\
key1: a,\
key2: b,\
key3: c\
}
return 1
How do you feel about it?
Ah, super, this looks good to me! Thanks @Schaeff.
If it's easy to infer a new line from a comma ,
instead, then that would be even better. But if it's too much work at this stage of development, then this issue can be closed (because a line break \
will still make my code much more readable than it was previously).