microsoft / qsharp-language

Official repository for design of the quantum programming language Q# and its core libraries
MIT License
233 stars 54 forks source link

Consider changing call precedence to be equal to or greater than `!`, `::`, and `[` `]` #138

Open bamarsha opened 2 years ago

bamarsha commented 2 years ago

I would like to write:

Complex(1.0, 0.0)!
Complex(1.0, 0.0)::Real
GetArray()[i]

But because of operator precedence, this is invalid syntax, and I have to instead parenthesize the calls:

(Complex(1.0, 0.0))!
(Complex(1.0, 0.0))::Real
(GetArray())[i]
cgranade commented 2 years ago

Big +1 to that. Grabbing named items out of a UDT value returned by a function or operation is a fairly common use-case, and currently is a bit awkward due to the extra ()s required.