tag:blogger.com,1999:blog-17087850.post2807704581677507683..comments2023-10-31T06:50:41.697-04:00Comments on Factor: a practical stack language: Working on inheritanceSlava Pestovhttp://www.blogger.com/profile/02768382790667979877noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-17087850.post-63727587890198590392008-04-02T18:21:00.000-04:002008-04-02T18:21:00.000-04:00"See Io and Self for languages based entirely on d..."See Io and Self for languages based entirely on delegation."<BR/><BR/>I'm aware of both. Io is very slow, and Self has a complex compiler. Self is also too dynamic for my taste.<BR/><BR/>"Factor can implement delegation with help from class inheritance because it can use other features of the language to mutate the class object -- but such mutation will always be slow and risky."<BR/><BR/>Factor's delegation implementation is independent of inheritance. Dan's code in extra/delegation is very clean and not risky at all.Slava Pestovhttps://www.blogger.com/profile/02768382790667979877noreply@blogger.comtag:blogger.com,1999:blog-17087850.post-59856904800218658502008-04-02T16:21:00.000-04:002008-04-02T16:21:00.000-04:00jengu, the problem is that there are too many dist...jengu, the problem is that there are too many distinct situations in which objects need to be substitutable. Look at the whole covariance/contravariance dispute, and think about all the situations in which both sides are right (one at a time, of course). C++ took the middle road, novariance, so it gets none of the benefits of either choice.wtanksleyhttps://www.blogger.com/profile/03283393679440645366noreply@blogger.comtag:blogger.com,1999:blog-17087850.post-14368570883333081132008-04-02T16:17:00.000-04:002008-04-02T16:17:00.000-04:00"if an object A delegates to B, then methods defin..."if an object A delegates to B, then methods defined on B no longer receive the instance of A on the stack, they receive the instance of B"<BR/><BR/>Wait, stop. That's not delegation; <A HREF="http://javalab.cs.uni-bonn.de/research/darwin/delegation.html" REL="nofollow">that's consultation</A>. It's a huge mistake to confuse them; it leads to errors such as deciding that class inheritance is more fundamental than object delegation.<BR/><BR/>Let me repeat: this is a huge mistake. See <A HREF="http://iolanguage.com" REL="nofollow">Io</A> and Self for languages based entirely on delegation.<BR/><BR/>Delegation can completely implement class inheritance at the same speed and with the same characteristics as at could have in a language-native implementation (assuming the same type system and compiler support, of course). Inheritance cannot implement delegation (at all). Factor can implement delegation with help from class inheritance because it can use other features of the language to mutate the class object -- but such mutation will always be slow and risky.<BR/><BR/>I suggest that reconsidering this might be a good idea.wtanksleyhttps://www.blogger.com/profile/03283393679440645366noreply@blogger.comtag:blogger.com,1999:blog-17087850.post-928931099062213072008-03-27T15:56:00.000-04:002008-03-27T15:56:00.000-04:00The okmij article is interesting, but it seems tha...The okmij article is interesting, but it seems that he's simply saying, "If you use inheritance badly it is bad." C++ programmers have been saying for years that inheritance is about substitutability, which means that subclasses are only about specialization to the extent that specialization adds no new <I>constraints</I>. His set/bag example is not good engineering practice as he claims.Jenguhttps://www.blogger.com/profile/13531274816722633428noreply@blogger.comtag:blogger.com,1999:blog-17087850.post-59722841148043649292008-03-27T10:50:00.000-04:002008-03-27T10:50:00.000-04:00For another, more reasoned, critique of implementa...For another, more reasoned, critique of implementation inheritance, I suggest:<BR/><BR/>http://okmij.org/ftp/Computation/Subtyping/<BR/><BR/>The argument is similar to misuse of is-a vs. has-a, though more subtle. Situations that appear to be clear is-a relationships are actually programming errors.<BR/><BR/>Granted, it could be considered an edge case. But if this knowledge can find home, why not Factor?Anonymousnoreply@blogger.com