Re: [swift-evolution] No disjunctions in type constraints: why?

2018-01-17 Thread Robert Widmann via swift-evolution
If you replace “conjunction” by “O(n) search with early-exit on failure” and 
“disjunction” by just “O(n) search”, you’ll see why this can lead to 
computationally painful systems of constraints.  Each disjunctive constraint 
may further contain or create disjunctions ad nauseum, each time incrementing 
the exponent in the worst-case time it takes to solve the system.  Introduction 
of disjunction into an already complex system (say, one that supports 
constrained parametric polymorphism and subtyping AND disjunctions through 
overloads) makes an already difficult problem even harder.

~Robert Widmann 

2018/01/13 4:45、Daryle Walker via swift-evolution 
のメール:

> From 
> .
> 
> Maybe I’m not up on my Type Theory, but why should type constraint 
> disjunctions be banned?
> 
> — 
> Daryle Walker
> Mac, Internet, and Video Game Junkie
> darylew AT mac DOT com 
> 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


Re: [swift-evolution] No disjunctions in type constraints: why?

2018-01-13 Thread Saagar Jha via swift-evolution
The “Swifty” way of doing such a thing is to have the types you care about 
conform to a protocol that clearly defines the API you’re trying to expose. For 
example:

protocol Fooable {
func doFoo()
}

extension Int: Fooable {
func doFoo() {
print("I’m an Int")
}
}

extension String: Fooable {
func doFoo() {
print("I’m a String")
}
}

Now, instead of a disjunctive Int | String union type you can just use Fooable 
and call doFoo on it when necessary:

func doSomethingWithAFooable(_ foo: Fooable) {
foo.doFoo()
}

doSomethingWithAFooable(0) // prints: I’m an Int
doSomethingWithAFooable("") // prints: I’m a String

Saagar Jha

> On Jan 13, 2018, at 01:45, Daryle Walker via swift-evolution 
>  wrote:
> 
> From 
>   
> >.
> 
> Maybe I’m not up on my Type Theory, but why should type constraint 
> disjunctions be banned?
> 
> — 
> Daryle Walker
> Mac, Internet, and Video Game Junkie
> darylew AT mac DOT com 
> 
> ___
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


[swift-evolution] No disjunctions in type constraints: why?

2018-01-13 Thread Daryle Walker via swift-evolution
>From 
>.

Maybe I’m not up on my Type Theory, but why should type constraint disjunctions 
be banned?

— 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 

___
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution