timotheecour / D_vs_nim

comparison of D vs nim
Apache License 2.0
62 stars 14 forks source link

Optional parens question #2

Closed ghost closed 6 years ago

ghost commented 6 years ago

I think Nim does support optional parens, for example:


proc a(data: int): int = data + 5
proc b(val: float): float = val - 3

let c = b float a 5 # Same as b(float(a(5)))
echo c  # Echoes 7.0

Or do you mean something else by optional parens?

timotheecour commented 6 years ago

@Yardanico

proc fun2():auto=return
fun2()
# fun2 # expression 'fun2()' has no type (or is ambiguous)
void fun2(){}
fun2; // calls fun2()

I've updated the readme, I'll let you close this if you're satisfied with that: https://github.com/timotheecour/D_vs_nim/commit/5f9d69907b36a5a567bc4b81a8b997b7d368c312

ghost commented 6 years ago

@timotheecour The third one is probably ambiguous because you can do that:

proc a() = echo 5
let b = a
a() # echoes 5
b() # echoes 5
timotheecour commented 6 years ago

right I understand the reasonning behind the difference in syntax; the update i made clarified the difference, closing