<div dir="ltr">As I understand it, and someone please correct me if I'm wrong, you've just described <i>existentials</i>, which Swift doesn't fully support yet but which are on the Generics Manifesto.<div><br></div><div>It would be nice to declare or cast a variable as 'conforms to protocol X with associated type known to be Y' or 'conforms to protocol X with associated type known to conform to Z'.</div><div><br></div><div>I don't know what syntax has been suggested / agreed upon for either of these, though.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 16, 2017 at 3:13 PM, Rtnm Nosurname via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello.<br>
<br>
Sorry, but C# code:<br>
<br>
interface IValidator<T> {<br>
bool validate(T value);<br>
}<br>
IValidator<String> validator;<br>
<br>
Easy, simple and clear.<br>
<br>
Swift:<br>
<br>
protocol PValidator {<br>
associatedtype ValidateType<br>
func validate(value: ValidateType) -> Bool<br>
}<br>
var validator: ????<br>
<br>
it can be so:<br>
var validator: PValidator where ValidateType == String<br>
<br>
or<br>
var validator: <T: PValidator> where ValidateType == String<br>
<br>
or<br>
var validator: PValidator<ValidateType == String><br>
<br>
or<br>
typealias StringValidator = PValidator<ValidateType == String><br>
var validator: StringValidator<br>
<br>
No matter how, but it should be.<br>
<br>
What alternatives offers swift?<br>
______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</blockquote></div><br></div>