> On Jan 12, 2017, at 16:50, Oscar Swanros via swift-evolution 
> <[email protected]> wrote:
> 
> Hello everyone. This is my first contribution to Swift Evolution. In summary: 
> It would be nice if the type casting operator accepted expressions on its 
> right side. 
> 
> So, basically, the type casting operator only accepts types and can't process 
> expressions on its right side.
> 
> Having a class A, and a subclass of A, B:
> 
> class A {}
> class B: A {}
> 
> And a function that returns the passed type:
> 
> func type<T: A>(t: T.Type) -> T.Type {
>     return t
> }
> 
> The following scenario works:
> 
> let b = B()
> let a = (b as A)
> 
> However the following scenario doesn't:
> 
> let b = B()
> let a = (b as type(A))
> 
> 
> Having the “as” accept expressions on its right side would be really useful 
> and could enable some truly great generic algorithm implementations.

+1 for the functionality, but I think it's part of the larger issue of 
"functions which can be evaluated at compile-time", which, IIRC, is presently 
considered out of scope (can't recall if that's just for phase 1 or Swift 4 
altogether). I might be wrong, though. I'm sure someone who knows more than I 
do will be along shortly with a better answer.

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

Reply via email to