Why do properties require explicit typing during compilation?

后端 未结 2 1609
时光说笑
时光说笑 2021-01-15 21:46

Compilation using property syntax requires the type of the receiver to be known at compile time. I may not understand something, but this seems like a broken or incomplete c

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-15 22:27

    Kevin nailed one of the symptoms.

    When designing properties, the very specific decision was made not to support id as the target of dot syntax. Beyond the ambiguities that Kevin points out, the desire to avoid all ambiguities related to (id) receivers was considered desirable.

    In general, the use of fully unqualified id is both undesirable and actively discouraged. In creating new features in the language, not supporting id discourages the proliferation fragile coding patterns across the new feature(s).

提交回复
热议问题