“can't existentially abstract over parameterized type…”

前端 未结 2 1169
攒了一身酷
攒了一身酷 2020-12-18 22:35

I was messing around with Scala 2.8 for fun and trying to define a pimp which adds an \"as\" method to type constructors, allowing to convert from one functor to another (pl

2条回答
  •  庸人自扰
    2020-12-18 22:49

    To me this sounds like a simplicity against generality case: there could be a new type variable generated every time a block is created capturing some type constructor instantiated with existential type, but that would make error diagnostics more difficult to understand.

    Also note that having a class turns the call into a fast INVOKEVIRTUAL, rather than invoking as() method by reflection.

提交回复
热议问题