tag:blogger.com,1999:blog-2447174102813539049.post7076023764071614736..comments2024-03-27T03:52:14.195-07:00Comments on Room 101: Subsuming Packages and other StoriesGilad Brachahttp://www.blogger.com/profile/17934280339206214042noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-2447174102813539049.post-25029875831266075482011-10-14T10:14:08.249-07:002011-10-14T10:14:08.249-07:00renoX:
First of all, since it's a presumably ...renoX:<br /><br />First of all, since it's a presumably mutable field, it would have to have the exact same type not a subtype.<br /><br />The attraction of hiding is that adding a field in a superclass does not break the subclass. Once you put any kind of constraint on that process, you lose that property and it is all rather pointless.Gilad Brachahttps://www.blogger.com/profile/17934280339206214042noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-39700857862681889142011-10-13T05:52:52.019-07:002011-10-13T05:52:52.019-07:00For the case 1, I find strange that your conclusio...For the case 1, I find strange that your conclusion is "It would be much better to ensure that fields are always private, or better yet, avoid field references altogether, as in Self or Newspeak.", IMHO what you show is that if you allow this then the language should enforce that T.f's type is a subtype of S.f so that the substition principle is preserved.renoXhttps://www.blogger.com/profile/03221431358667243128noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-14596725238668590622011-09-06T08:56:58.563-07:002011-09-06T08:56:58.563-07:00No. It's what they are all about. Privacy is a...No. It's what they are all about. Privacy is achieved by type abstraction (rather than by procedural abstraction).Gilad Brachahttps://www.blogger.com/profile/17934280339206214042noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-74103413547462323612011-09-06T07:49:50.012-07:002011-09-06T07:49:50.012-07:00And isn't privacy/privacy per type just an imp...And isn't privacy/privacy per type just an implementation detail of ADTs? <br /><br />AdamAdam Warskihttps://www.blogger.com/profile/04535036247623614805noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-57789252070231558852011-09-05T07:38:07.376-07:002011-09-05T07:38:07.376-07:00Adam, the key property of ADTs here is privacy PER...Adam, the key property of ADTs here is privacy PER TYPE.Gilad Brachahttps://www.blogger.com/profile/17934280339206214042noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-81965865121265400542011-09-05T02:03:09.195-07:002011-09-05T02:03:09.195-07:00Thanks! It's a bit more clear now.
You've...Thanks! It's a bit more clear now.<br /><br />You've used inheritance and subsumption in the example, but what's the crucial property of ADT's that matters here? Private/public features?<br /><br />ADT's have a rather vague definition (at least to my knowledge; no doubt there are concrete ones, but these are rather used in specific papers), that's why I'm not sure what you exactly mean when writing "ADT".<br /><br />AdamAdam Warskihttps://www.blogger.com/profile/04535036247623614805noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-79268773210710668932011-09-02T18:51:54.446-07:002011-09-02T18:51:54.446-07:00Adam:
Say you have ADT_S with abstract typpe S, w...Adam:<br /><br />Say you have ADT_S with abstract typpe S, with private feature m of type int. You extend this with ADT_T with abstract type T. T has feature m of type String. No contradiction, as ADT_T cannot see the unexposed feature m of S. Now suppose you add <br /><br />foo(T t){return t.m;} <br /><br />to ADT_S. What is the type of the returned value? It seems obvious that it is String. But t also has type S by subsumption, and so one can prove that t.m has type int.Gilad Brachahttps://www.blogger.com/profile/17934280339206214042noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-61662615032433130982011-09-02T06:29:07.974-07:002011-09-02T06:29:07.974-07:00Sorry if it's something basic, but why can'...Sorry if it's something basic, but why can't you have inheritance, ADTs and subsuming? I tried googling but without much luck.<br /><br />Thanks,<br />Adam WarskiAdam Warskihttps://www.blogger.com/profile/04535036247623614805noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-44793514404323363652009-03-31T14:19:00.000-07:002009-03-31T14:19:00.000-07:00i was surprised to hear anybody likes inheritance!...i was surprised to hear anybody likes inheritance! but i'm only coming from mostly a C++/C#/Java world, not from say the Smalltalk-derived world. i would very much like to hear and learn about your thoughts and experience wrt inheritance. (in and of itself, but also wrt ATDs would be quite interesting.)<BR/><BR/>thanks for all your efforts, btw. e.g. this post really helps me understand more about what the heck java is doing; things i just sort of accepted but really didn't grok at all.Raoul Dukehttps://www.blogger.com/profile/07354740962526930549noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-59297560876670015272009-03-30T09:10:00.000-07:002009-03-30T09:10:00.000-07:00I believe the benefits of inheritance far outweigh...<I>I believe the benefits of inheritance far outweigh the costs.</I><BR/><BR/>I'm not convinced the benefits of inheritance are really all that compelling. Perhaps you should enumerate these benefits, because they're a lot less clear than the benefits of subsumption.Sandro Magihttps://www.blogger.com/profile/05446177882449578817noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-38081553472299824392009-03-30T07:49:00.000-07:002009-03-30T07:49:00.000-07:00Hi Yardena,Thanks for the link. A quick scan indic...Hi Yardena,<BR/><BR/>Thanks for the link. A quick scan indicates it goes through much of the brutal detail I was reluctant to spend time/space on. Maybe I'll update the post to link to it.<BR/><BR/>Of course my emphasis is not on the specific problems of Java packages, but on what underlies them. That is the way to avoid language puzzlers.Gilad Brachahttps://www.blogger.com/profile/17934280339206214042noreply@blogger.comtag:blogger.com,1999:blog-2447174102813539049.post-40036124702009797282009-03-30T00:34:00.000-07:002009-03-30T00:34:00.000-07:00Great post. Here's a relatively recent account of ...Great post. Here's a relatively recent account of cognitive mismatch between inheritance and package privacy, titled no less than <A HREF="http://dow.ngra.de/2009/02/16/the-ultimate-java-puzzler/" REL="nofollow">The Ultimate Java Puzzler</A>.Yardenahttps://www.blogger.com/profile/15649241856669571499noreply@blogger.com