[swift-evolution] [swift-evolution-announce] [Review] SE-0091: Improving operator requirements in protocols

Brent Royal-Gordon brent at architechies.com
Wed May 18 02:10:32 CDT 2016


> Or should the compiler only allow those two argument labels for unary operator functions? That feels strange since it's not a restriction present anywhere else, and it starts to feel like the labels have a dual purpose that also falls into the realm of keywords.

A similar restriction exists on operators currently. Today, Swift does not allow keywords on operator parameters:

 23> prefix func !<T>(prefix value: T) {}
repl.swift:23:18: error: operator cannot have keyword arguments
prefix func !<T>(prefix value: T) {}
                 ^~~~~~~

What I'm suggesting is that, on unary operators, Swift require either the keyword "prefix" or "postfix" on the argument, and use that to differentiate between prefix and postfix operators. No other keyword would be used or permitted, and no keyword would be used or permitted on infix operators' arguments.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list