[swift-evolution] For-loop revisited

Pyry Jahkola pyry.jahkola at iki.fi
Fri Feb 26 02:42:32 CST 2016

On 26 Feb 2016, at 04:26, Dave Abrahams via swift-evolution <swift-evolution at swift.org> wrote:
> on Thu Feb 25 2016, ted van gaalen <swift-evolution at swift.org> wrote:
>> (btw: If I don't put () around -60 , then the compiler complains with
>> "Unary operator '-' cannot be applied to an operand of type 'StrideTo<Double>' "
>> Could this be a compiler error? Shouldn't it first instantiate or evaluate the 
>> numerical object,before glueing the .stride()  to it? ) 
> Please file a bug report!

Doesn't seem like a bug to me. In general, we want to allow an expression like -rect.width to return the negative width, and not apply the unary operator to rect first. Same goes to -array.reduce(0, combine: +), for example.

Hence, member access and function application bind tighter than prefix operators.

— Pyry

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160226/8652f16a/attachment.html>

More information about the swift-evolution mailing list