What have you found for these years?


Is proper variance compatible with objects/classes?

updated 2011-10-14 00:03
Oh wait, so true! See what Martin Odersky said.
So actually it's a natural consequence of covariant lists.
If we really want that kind of type safety in elem method,
then actually we're looking for invariant lists instead.

Then it's a non-issue at all, if we have both kind of lists.

* * *

Is proper variance compatible with objects/classes?

閱讀這篇時,發覺自己已經忘記之前在 Scala 裡讀到的 variance 細節...
1658. 05-02 scala type system (1) covariance and contravariance
1655. 05-02 scala type system (0) unit, top, bottom, and null


簡單地說就是,應該沒有理想解吧。像 Scala 這樣說不定就是最好的狀況了。
但是說真的,這寫起來就很彆扭,總讓我有種還不如去用 Haskell 算了的感覺。
從完全相反的角度來看的話,那又何苦把事情搞得這麼複雜,像 Java 那樣
大家都 Object 然後不斷 type cast 然後 catch exception 不就得了?
C++ template 那又是另一回事....

再想想我一直沒完全搞懂的 ML module

再瞧瞧一直還沒細看 Josh 的 Modularising Inductive Families

模組化真的是個很難搞的東西... 偏偏寫大程式又一定要模組化。

0 retries:

Post a Comment

Note: Only a member of this blog may post a comment.

All texts are licensed under CC Attribution 3.0