Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It is not essential, and neither is covariance. For instance, C and C++ function types are invariant (but C++ virtual member functions are properly variant, and so is std::function). If a language does not support variance, it can always be emulated with wrapper functions. Eg. given types A :> B :> C

    fn foo: (B -> B) -> ()
    fn bar: A -> C

    foo(b -> bar(b))
where the lambda has (inferred) type B -> B.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: