Equivalent implicit operators: why are they legal?

后端 未结 2 1225
长情又很酷
长情又很酷 2021-01-05 11:04

Update!

See my dissection of a portion of the C# spec below; I think I must be missing something, because to me it looks like the behavior I\'

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-05 11:42

    Ultimately, it can't be prohibitted with complete success. You and I could publish two assemblies. They we could start using each other's assembles, while updating our own. Then we could each provide implicit casts between types defined in each assembly. Only when we release the next version, could this be caught, rather than at compile time.

    There's an advantage in not trying to ban things that can't be banned, as it makes for clarity and consistency (and there's a lesson for legislators in that).

提交回复
热议问题