Rei Miyasaka
Rei Miyasaka

Reputation: 7126

Strange expression parsing behavior

In this code:

let f(a,b,c) = a * b + c - (d())
let g(a,b,c) = a * b + c -(d())

f is (int*int*int) -> int, and g is (int*int*(int*int)) -> int.

Removing the brackets around d() in g causes the "Successive arguments should be separated by spaces or tupled" error.

What's going on?

Upvotes: 3

Views: 201

Answers (1)

ildjarn
ildjarn

Reputation: 62995

@bytebuster is quite correct in his comment, but to put it into layman's terms ;-] one is parsed as the binary subtraction operator and the other is parsed as the unary negation operator – you're simply fighting operator precedence here.

Upvotes: 2

Related Questions