2 ms·
Indeed. Nim also has significant whitespace, and your example translated: proc some_function(a, b: proc(a: int): int) = echo a(1) echo b(2)
by shiomiru 3y ago
Indeed. Nim also has significant whitespace, and your example translated:
proc some_function(a, b: proc(a: int): int) =
echo a(1)
echo b(2)
some_function(proc(a: int): int =
return a
, proc(b: int): int =
return b)
is valid Nim and compiles just fine.
(Also, "1, 2" is not valid Nim, so unlike with Python you can just put the comma
right after `a' without syntactic ambiguity.)
- o11c 3y agoFollowing the aside ... requiring parentheses around tuples is generally best for readability. I can only think of two cases that are more readable without them: (x, y) = (y, x) some_array[(x, y)] Languages generally already special-case both the LHS of assignments and the inside of indexing brackets, and special-casing the RHS of assignments seems like a reasonable extension.
- cb321 3y agoTo amplify your "comma right after", the call can even be simply: some_function(proc(a: int): int = a, proc(b: int): int = b) And Nim lets you put ()s in a great many places to resolve problems. I find its syntax quite a bit nicer than Python, actually.