> Am 21.01.2017 um 21:31 schrieb Dave Abrahams via swift-evolution 
> <[email protected]>:
> 
>> I'm struggling a little with the naming and syntax, but as a general 
>> approach, I think we want people to use something more like this:
>> 
>>    if StringOptions(case: .insensitive, locale: .current).compare(foo < bar) 
>> { … }
> 
> Yeah, we can't do that without making 
> 
>       let a = foo < bar
> 
> ambiguous
> 

Hi,

the most swifty way to write this I can imagine is something like:

    func <(_ a: Int, _ b: Int, case: Case = .insensitive, locale: Locale = 
.current)
    
    let a = foo < bar where <(case: .insensitive, locale: .current) 

In other words, function or operator calls can be splitted:

    func foo(_ a: Int, _ b: Int, option: Option)
    
    let res = foo(10, 20) where foo(option: .fast)

And where it is unambiguous the second function or operator name can be omitted:

    let a = foo < bar where (case: .insensitive, locale: .current)

...or shared:

    let a = foo1 < bar1 && foo2 < bar2 where (case: .insensitive, locale: 
.current)

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

Reply via email to