> On Oct 26, 2016, at 21:29, Jay Abbott <[email protected]> wrote:
> 
> David, you can use two binary operators (or overload the same one twice if 
> you want) to create syntax that behaves like a ternary operator.
> 
Oh I know, it's just kinda clunky and inefficient sometimes, if you need to 
wrap a value in a struct or something simply to avoid ambiguity or enforce the 
correct syntax. It's not quite the same thing a ternary operator, but at one 
point I'd added `|` as both pre and postfix operators to allow code like "let y 
= |x|". The left `|` had to return a `_PartialAbsValueOp` and the right one had 
to take the same to invalidate the "let y = |x" or "let y = x|" syntax, one of 
which would've otherwise worked (depending on which op actually called "abs()").

I should've been clearer that I was talking about support for "free form" 
operators in general, including ternary ops, so that we don't have to fake them 
by declaring some # of traditional pre/in/postfix operators which all then have 
to work together (possibly exclusively, depending on the desired syntax), and 
might have to pass wrapper types around solely to help explain your syntax to 
the compiler.

Thanks for pointing it out, though. That's an easy trick to forget about.

- Dave Sweeris
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to