Seen on https://nim-by-example.github.io/block/
Parentheses can be used as an expression, but they do not provide end of statement inference, so it is necessary to place semicolons yourself. An interesting and unexpected side effect of this syntax is that Nim is suitable even for die-hard brace purists!
While possible, it doesn’t mean it’s a good idea. Most Nim code does not use parentheses in that way, and it would not be seen as idiomatic.
proc square(inSeq: seq[float]): seq[float] = (
result = newSeq[float](len(inSeq));
for i, v in inSeq: (
result[i] = v*v;
)
)
How comes, then, that this works:
for i in 1..10:
echo "hello"
echo i
and this doesn't:
for i in 1..10: (
echo "hello";
echo i;
)
I see.
Thank you!
I actually like that alternative (or "complement") rather. I don't trust copy/paste operations when I don't have visible delimiters.
For Python, I use "pindent.py" to add visible "# end for", "# end def", etc. delimiters