[swift-evolution] Proposal: Introduce User-defined "Dynamic Member Lookup" Types

Benjamin G benjamin.garrigues at gmail.com
Sun Dec 3 18:13:01 CST 2017


On Mon, Nov 27, 2017 at 8:03 PM, Chris Lattner via swift-evolution <
swift-evolution at swift.org> wrote:

> On Nov 27, 2017, at 8:57 AM, Mathew Huusko V <mhuusko5 at gmail.com> wrote:
> > You're saying that there is universally no inherent difference, and that
> all calls "determine if you have called it" correctly, but then picked one
> of only a handful of cases in current practice where that is actually true.
> Yes "+" (/other math operators) and array access are unsafe, but most other
> things in Swift are safe by default, and you have to opt into un-safety
> (e.g. forcing or checking an optional or throwing call) — this is a main
> tenant of the language.
>
> There is nothing unsafe about this proposal.  It is fully type safe and
> supports failable operations (by having the properties typed as
> optionals).  This is shows by example in the proposal.
>
> Your explanation above is so confusing to me.  The closest analog to this
> feature is AnyObject dynamic lookup, which *is* completely unsafe, and is
> pervasively tangled throughout the compiler.   Maybe you’re confusing the
> two.
>


I've seen people in this thread mention AnyObject dynamic lookup as
something similar to the proposal. But there's something i don't understand
:
var a: AnyObject
a.anyFunc()

is a compiler error.

Whereas
var a: PyObject (or anything conforming to DynamicLookup depending on the
option from the proposal)
a.anyFunc()

would be perfectly fine. What's the part i didn't get ?



>
> -Chris
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171204/c4312146/attachment.html>


More information about the swift-evolution mailing list