The bad thing about existing nominally typed OO PLs is that you can't post-hoc let a class implement an interface. If you could add new methods to any class, and then declare that the class now implements a new interface, you'd get the practical benefits of structural typing.
-
-
Replying to @msimoni
Uh? CLOS generic functions, Haskell typeclasses, Clojure protocols, Rust interfaces, etc., have both nominal classes and post-hoc implementation. Just because Java and C++ are extremely bad languages doesn't mean the concept of nominal classes is itself deficient.
1 reply 0 retweets 1 like -
Replying to @Ngnghm
In which of these languages can I do this: add new methods to class C, declare that C now implements interface I, and now have every instance of C be an instance of I?
1 reply 0 retweets 0 likes -
-
Replying to @Ngnghm
in CLOS you'd need to redefine C with I as superclass afaict
3 replies 0 retweets 0 likes -
Wouldn't having a predicate function that uses COMPUTE-APPLICABLE-METHODS over all the GFs of the interface suffice?
1 reply 0 retweets 1 like -
Replying to @PuercoPop @Ngnghm
my point is that I want instances of C to be instances of I (for the purposes of TYPEP)
1 reply 0 retweets 0 likes -
Replying to @msimoni @PuercoPop
I'm not sure why you want (TYPEP x 'MY-INTERFACE) to work as opposed to (MY-INTERFACE-P x) or (IMPLEMENTSP x <MY-INTERFACE>); but if you insist, the CLOS MOP will be happy to oblige. Meanwhile, I encourage you to try interface-passing stylehttps://github.com/fare/lisp-interface-library …
1 reply 0 retweets 1 like -
Replying to @Ngnghm @PuercoPop
so that there's a single notion of type, that can be used e.g. as a generic type parameter.
2 replies 0 retweets 0 likes
I invite you to use interface-passing style rather than cl:typep, especially if you're going to pass types as parameters. But if you are emotionally attached to cl:typep, use the CLOS MOP.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
Read my blog!