> And thus the fragile superclass problem is born.
> > The thing is, there are two overlapping but different perspectives > here. From an object-centric view, sure, any state or behavior is > there in the object and where in the hierarchy it comes from is a > minor detail. > > However, as far as the code goes, we are talking about distinct chunks > of code, potentially written, maintained and updated by different > people. A subclass depends on the superclass in the same way that code > using a library is a dependent of that library's API. Managing that > dependency has maintainability repercussions, and weakening it is a > good thing. > > Cheers, > > --Vassili Not at the expense of encapsulation by forcing access to instance variables to go through public accessors. Protected accessors (visible only to self and subclasses) might be a compromise but then you open up the whole can of worms going down that path where the language starts trying to protect the programmer from himself with all kinds of visibility options for methods and classes. This leads to things like csharp and java's final/sealed classes where the author of a class decides all future uses of the class. I prefer a language to enable me, not restrict me. I don't want the author of a class deciding for me how I might decide to use that class in the future. If the fragile base class problem is the price, then I'm happy to pay it. Ramon Leon http://onsmalltalk.com |
In reply to this post by Tony Garnock-Jones-2
"Smalltalk-the-artifact is simultaneously a great improvement on its
successors and a system unsuitable for serious use." Eeeek! Don't think I'd go that far. Smalltalk-the-artifact is certainly suitable for serious work. It's paid my bills a number of times and is still used quite seriously in industry. |
David Mitchell wrote:
> Smalltalk-the-artifact is certainly suitable for serious work. It's > paid my bills a number of times and is still used quite seriously in > industry. Agreed. I was deliberately being pithy. :-) Perhaps I should have said "simultaneously a great improvement on its successors and a flawed system in need of serious revision." (Plenty of seriously flawed systems get serious use. What intrigues me is considering the reasons why Unix is vastly more popular than Smalltalk -- they're broadly comparable. I think the answer is to do with trust boundaries, shared state, and structured metaprogramming. That's a handwave, of course :-) ) Tony |
In reply to this post by jgfoster
James Foster a écrit :
> > On Nov 25, 2008, at 7:45 PM, Igor Stasenko wrote: >> My understanding of inheritance is different, in short: >> A subclass of particular class is a _specialization_ of base class, >> not _expansion_. > > In this context, I sometimes wonder if Square should inherit from > Rectangle (a specialization in which width and height are equal), or > Rectangle should inherit from Square (adding an instance variable). Am I > right that you would have Square inherits from Rectangle (Square being > more specialized)? But then it feels like we are wasting an instance > variable (since Rectangle would have two). > > James > > Beware, you're dangerously sliping to multiple inheritance because your Square might also be a lozenge :) Nicolas |
In reply to this post by Eliot Miranda-2
On 26-Nov-2008, at 1:32 PM, Eliot Miranda wrote: > > Then choose a different class than SmallInteger to make your point. Sorry, it wasn't my choice in the first place. I'm not sure it's relevant to my point either, but I'm too ignorant about the details to know for sure so I'll take your word for it. I think any normal class would do, though perhaps any user-defined class would be best -- the point is simply that subclasses are defined by adding stuff to the definition of an existing class hierarchy. Whether the additions change the behaviour of existing methods or not, add new instance variables, or not, or add new methods or not, doesn't really take away from the fact that the subclass is defined by adding new definitions to its superclass. Any class (except I think Object itself of course) is really just the combined definition of all the superclasses in its hierarchy. If it weren't for "super" (and some other meta-level stuff I think we can safely gloss over) there would be no real way for an object to distinguish which parts of itself are from which levels in the class hierarchy that it is entirely derived from. At least that's how I've come to understand classes and inheritance in Smalltalk-80. -- Greg A. Woods; Planix, Inc. <[hidden email]> PGP.sig (193 bytes) Download Attachment |
In reply to this post by Tony Garnock-Jones-2
On 26-Nov-2008, at 1:54 PM, Tony Garnock-Jones wrote: > Greg A. Woods; Planix, Inc. wrote: >> I.e. you could sort of create a subclass by simply copying the >> whole class definition you wish to inherit from, then modify it to >> your liking (this has been done an infinite number of times in uses >> of non-OO languages!). However then you lose the support of the >> system to maintain the relationship between the shared parts of the >> superclass definition(s) and the subclasses that inherit from it >> (or indeed even just between the superclass and its sole subclass >> in the case where the superclass is not actually an abstract class). > > Traits? I definitely don't know how Traits would/could work in Smalltalk and what benefit they would bring. Does anyone have a reference to a good outline of what Traits do for Smalltalk? Do they provide the ability to hide instance variables from subclasses -- or eliminate the need for recompiling subclasses? Do they simply add a new feature, or do they replace something in (or even all of) classes or metaclasses? -- Greg A. Woods; Planix, Inc. <[hidden email]> PGP.sig (193 bytes) Download Attachment |
In reply to this post by Ramon Leon-5
On 26-Nov-2008, at 2:41 PM, Ramon Leon wrote: > > Not at the expense of encapsulation by forcing access to instance > variables > to go through public accessors. Protected accessors (visible only > to self > and subclasses) might be a compromise but then you open up the whole > can of > worms going down that path where the language starts trying to > protect the > programmer from himself with all kinds of visibility options for > methods and > classes. > > This leads to things like csharp and java's final/sealed classes > where the > author of a class decides all future uses of the class. I prefer a > language > to enable me, not restrict me. I don't want the author of a class > deciding > for me how I might decide to use that class in the future. If the > fragile > base class problem is the price, then I'm happy to pay it. Exactly. :-) This is even hinted at broadly in the blue book -- i.e. its not a new problem by any stretch of the imagination. In fact I think this is where things outside the language and its implementation are more suitable to help with such problems. Eg. tools in the development environment, perhaps using structured documentation built into class definitions, might offer the necessary bridge. Perhaps something like a (pardon my association) lint-like tool for seeking out and managing inter-class dependencies and constraints (because this issue extends beyond just subclasses and superclasses and cuts across all classes which interact in any way). -- Greg A. Woods; Planix, Inc. <[hidden email]> PGP.sig (193 bytes) Download Attachment |
In reply to this post by Greg A. Woods; Planix, Inc.
www.iam.unibe.ch/~scg/Research/Traits
See also prior discussions on traits on this list: http://www.google.com/search?&q=site%3Ahttp%3A%2F%2Flists.squeakfoundation.org%2Fpipermail%2Fsqueak-dev%2F+traits On Wed, Nov 26, 2008 at 2:32 PM, Greg A. Woods; Planix, Inc. <[hidden email]> wrote: > > On 26-Nov-2008, at 1:54 PM, Tony Garnock-Jones wrote: > >> Greg A. Woods; Planix, Inc. wrote: >>> >>> I.e. you could sort of create a subclass by simply copying the whole >>> class definition you wish to inherit from, then modify it to your liking >>> (this has been done an infinite number of times in uses of non-OO >>> languages!). However then you lose the support of the system to maintain >>> the relationship between the shared parts of the superclass definition(s) >>> and the subclasses that inherit from it (or indeed even just between the >>> superclass and its sole subclass in the case where the superclass is not >>> actually an abstract class). >> >> Traits? > > Maybe. I don't know. > > I definitely don't know how Traits would/could work in Smalltalk and what > benefit they would bring. > > Does anyone have a reference to a good outline of what Traits do for > Smalltalk? Do they provide the ability to hide instance variables from > subclasses -- or eliminate the need for recompiling subclasses? Do they > simply add a new feature, or do they replace something in (or even all of) > classes or metaclasses? > > -- > Greg A. Woods; Planix, Inc. > <[hidden email]> > > > > > |
In reply to this post by Tony Garnock-Jones-2
Tony Garnock-Jones wrote:
> Bert Freudenberg wrote: > > Just a meta remark - I find it highly amusing how people dissect the > > Gospel of Alan, even interpreting it literally. He must get quite a > > chuckle from that ;) > > Well I hope so! :-) Given how happy he said he was to not have any disciples, he might be less than amused to find out otherwise ;-) Going to the other extreme, where everyone's opinion is equally valid, leads to situations like a guy explaining to me on comp.lang.lisp that multiple dispatch is the most important feature of OOP and so CLOS and C++ are true OO languages but Smalltalk is not. >http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/b2aa1842ccb7d7c/134456502780e63f?hl=en&lnk=gst&q=jecel#134456502780e63f -- Jecel |
In reply to this post by Nicolas Cellier-3
nicolas cellier wrote:
> James Foster a écrit : > > > > On Nov 25, 2008, at 7:45 PM, Igor Stasenko wrote: > >> My understanding of inheritance is different, in short: > >> A subclass of particular class is a _specialization_ of base class, > >> not _expansion_. > > > > In this context, I sometimes wonder if Square should inherit from > > Rectangle (a specialization in which width and height are equal), or > > Rectangle should inherit from Square (adding an instance variable). Am I > > right that you would have Square inherits from Rectangle (Square being > > more specialized)? But then it feels like we are wasting an instance > > variable (since Rectangle would have two). > > Beware, you're dangerously sliping to multiple inheritance because your > Square might also be a lozenge :) With the Rectangle as subclass of Square option this wouldn't be a problem - you would just have two different subclasses of Square. Could Rectangle be a subclass of Square? Sure: - Square instance variables: center, size, orientation - Rectangle adds this instance variable: aspectRatio We can make Ellipse a subclass of Circle using the same style. We can even have an #aspectRatio method in Square and Circle which always returns 1 and then we can move some of the more general code up in the classes hierarchy if we want to. For raster graphics it is convenient to define Rectangles as always parallel to the screen axis so that just two points are enough to fully identify them. Perhaps calling them RasterRects instead would have made us think more clearly about them. We later moved to vector graphics (Balloon) but were stuck with the historic baggage. -- Jecel P.S.: I am aware that even in this scheme you might want Parallelogram to inherit from both Rectangle and Lozenge (actually, Rhombus is more generic) and then you have the multiple inheritance problem again. Which is what Traits are for... |
In reply to this post by Tony Garnock-Jones-2
On Thu, Nov 27, 2008 at 3:54 AM, Jecel Assumpcao Jr <[hidden email]> wrote:
> Tony Garnock-Jones wrote: >> Bert Freudenberg wrote: >> > Just a meta remark - I find it highly amusing how people dissect the >> > Gospel of Alan, even interpreting it literally. He must get quite a >> > chuckle from that ;) >> >> Well I hope so! :-) > > Given how happy he said he was to not have any disciples, he might be > less than amused to find out otherwise ;-) > > Going to the other extreme, where everyone's opinion is equally valid, > leads to situations like a guy explaining to me on comp.lang.lisp that > multiple dispatch is the most important feature of OOP and so CLOS and > C++ are true OO languages but Smalltalk is not. > >>http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/b2aa1842ccb7d7c/134456502780e63f?hl=en&lnk=gst&q=jecel#134456502780e63f I know I shouldn't react, but could you just dissect for me how Alan's post, either the one before or the one after the post of yourself you linked here, makes the point you're suggesting him to be making? Is it the 'I've no idea where I'm going with this.' part perhaps? /Ties |
In reply to this post by Bert Freudenberg
2008/11/26 Bert Freudenberg <[hidden email]>:
> On 26.11.2008, at 09:48, Igor Stasenko wrote: > >> 2008/11/26 Trygve Reenskaug <[hidden email]>: >>> >>> On 26.11.2008 05:32, Igor Stasenko wrote: >>>> >>>> 1. Everything is an object >>>> 2. Objects communicate by sending and receiving messages (in terms of >>>> objects) >>>> 3. Objects has their own memory (in terms of objects) >>>> ---- >>>> 4. Every object is an instance of class (which must be an object) >>>> 5. The class holds the shared behavior for its instances (in the form >>>> of objects in a program list) >>>> 6. To eval a program list, control is passed to the first object and >>>> the remainder is treated as its message >>>> >>>> so, where in these statements you find anything about inheritance, or >>>> something where it says that subclass(es) should have any assumptions >>>> about the ways how superclass is storing its instances in memory, and >>>> therefore a subclass allowed to directly manipulate the object's state >>>> without consulting with superclass? >>> >>> I'm afraid Alan wasn't as precise as he should have been here. >> >> I think he did this intentionally, because a precise parts is up to >> implementation. >> The principles above is most generic ones. Btw, notice a line between >> 3 and 4, its not just a random stroke - its actually shows a first >> step from most generic to more specific. > > > Just a meta remark - I find it highly amusing how people dissect the Gospel > of Alan, even interpreting it literally. He must get quite a chuckle from > that ;) > :) i didn't meant to dissect it. Just wanted to point out, that we in the same boat (smalltalk) as long as design follows these basic principles. The rest is implementation details. > - Bert - > -- Best regards, Igor Stasenko AKA sig. |
In reply to this post by Ties Stuij
On 26.11.2008, at 22:38, Ties Stuij wrote: > On Thu, Nov 27, 2008 at 3:54 AM, Jecel Assumpcao Jr <[hidden email] > > wrote: >> Tony Garnock-Jones wrote: >>> Bert Freudenberg wrote: >>>> Just a meta remark - I find it highly amusing how people dissect >>>> the >>>> Gospel of Alan, even interpreting it literally. He must get quite a >>>> chuckle from that ;) >>> >>> Well I hope so! :-) >> >> Given how happy he said he was to not have any disciples, he might be >> less than amused to find out otherwise ;-) >> >> Going to the other extreme, where everyone's opinion is equally >> valid, >> leads to situations like a guy explaining to me on comp.lang.lisp >> that >> multiple dispatch is the most important feature of OOP and so CLOS >> and >> C++ are true OO languages but Smalltalk is not. >> >>> http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/b2aa1842ccb7d7c/134456502780e63f?hl=en&lnk=gst&q=jecel#134456502780e63f > > I know I shouldn't react, but could you just dissect for me how Alan's > post, either the one before or the one after the post of yourself you > linked here, makes the point you're suggesting him to be making? > > Is it the 'I've no idea where I'm going with this.' part perhaps? I know I shouldn't respond, but did you read further up in the thread, where Alan (Crowe) described how even the "simplest" things are impossible without multiple dispatch, which made him despise Smalltalk on his first encounter, an event he recites quite colorfully, with phrases like "I found this incomprehensibly awful. It completely destroyed the object metaphor. [...] I fled in horror from this hideous, mutilating language." - Bert - |
In reply to this post by Ties Stuij
Ties Stuij wrote:
> On Thu, Nov 27, 2008 at 3:54 AM, Jecel Assumpcao Jr wrote: > > Going to the other extreme, where everyone's opinion is equally valid, > > leads to situations like a guy explaining to me on comp.lang.lisp that > > multiple dispatch is the most important feature of OOP and so CLOS and > > C++ are true OO languages but Smalltalk is not. > > > >>http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/b2aa1842ccb7d7c/134456502780e63f?hl=en&lnk=gst&q=jecel#134456502780e63f > > I know I shouldn't react, but could you just dissect for me how Alan's > post, either the one before or the one after the post of yourself you > linked here, makes the point you're suggesting him to be making? > > Is it the 'I've no idea where I'm going with this.' part perhaps? Sorry - I gave a link to the first result that was in the thread I was remembering (this was three years ago, after all). The actual discussion I was thinking of was between Pascal Costanza and Alan Crowe much closer to the start of the thread (message 48 or so). My point was that dicussions become harder when everyone's definitions are equally valid. See the confusion around strong/weak/static/dynamic typing, for example. -- Jecel |
In reply to this post by Colin Putney
Hi Colin -
I was looking over SystemEditor and one thing that really surprised me was the use of ClassEditors as proxies. What is the reasoning behind it? It makes the design difficult to understand and extremely hard to debug - I gave up trying to find out what causes the issue with class migration when I effectively couldn't debug the editors since all they would show me were those pretend-classes. Is there some sort of debug mode to turn off all that evil magic? ;-) Cheers, - Andreas Colin Putney wrote: > > On 25-Nov-08, at 11:21 PM, Andreas Raab wrote: > >> Holy cow. If that actually works, it's impressive as hell. Given the >> complexity in ClassBuilder (all of which is the direct result of >> people actually using it and running into issues) it'll be no small >> feat to get this right in SystemEditor. I've spent a few years on it ;-) > > It shows. ClassBuilder isn't actually that hard to understand. The > constraints are hairy, but the code is fairly straightforward and has > lots of comments. > > In SystemEditor, those constraints are encapsulated in ClassFormat, with > unit tests. The tests probably aren't as complete as they could be, but > it gives us a place to document issues as they come up. > > I'm looking forward to reenabling atomic commits in Monticello2. The > speed improvement there is even greater, because right now, MC2 takes a > speed hit from loading instance variables one at a time. > > Colin > > |
On Wed, Nov 26, 2008 at 02:53:17PM -0800, Andreas Raab wrote:
> Hi Colin - > > I was looking over SystemEditor and one thing that really surprised me > was the use of ClassEditors as proxies. What is the reasoning behind it? > It makes the design difficult to understand and extremely hard to debug > - I gave up trying to find out what causes the issue with class > migration when I effectively couldn't debug the editors since all they > would show me were those pretend-classes. Is there some sort of debug > mode to turn off all that evil magic? ;-) yes. from the context of a class editor, do this: self system debug: true I got fed up with that myself today and made debug mode the default. I havn't committed that change yet. The problem with migration is most likely in InstanceMigrator. I'm looking into that myself. It is a new bug. This used to work. -- Matthew Fulmer -- http://mtfulmer.wordpress.com/ |
On Wed, Nov 26, 2008 at 03:59:48PM -0700, Matthew Fulmer wrote:
> On Wed, Nov 26, 2008 at 02:53:17PM -0800, Andreas Raab wrote: > > Hi Colin - > > > > I was looking over SystemEditor and one thing that really surprised me > > was the use of ClassEditors as proxies. What is the reasoning behind it? > > It makes the design difficult to understand and extremely hard to debug > > - I gave up trying to find out what causes the issue with class > > migration when I effectively couldn't debug the editors since all they > > would show me were those pretend-classes. Is there some sort of debug > > mode to turn off all that evil magic? ;-) > > yes. from the context of a class editor, do this: > > self system debug: true > > I got fed up with that myself today and made debug mode the > default. I havn't committed that change yet. Committed: SystemEditor-Squeak-mtf.160 > The problem with migration is most likely in InstanceMigrator. > I'm looking into that myself. It is a new bug. This used to > work. > > -- > Matthew Fulmer -- http://mtfulmer.wordpress.com/ > -- Matthew Fulmer -- http://mtfulmer.wordpress.com/ |
In reply to this post by Ramon Leon-5
On Wed, Nov 26, 2008 at 11:41 AM, Ramon Leon <[hidden email]> wrote:
>> However, as far as the code goes, we are talking about distinct chunks >> of code, potentially written, maintained and updated by different >> people. A subclass depends on the superclass in the same way that code >> using a library is a dependent of that library's API. Managing that >> dependency has maintainability repercussions, and weakening it is a >> good thing. > > Not at the expense of encapsulation by forcing access to instance variables > to go through public accessors. Protected accessors (visible only to self > and subclasses) might be a compromise but then you open up the whole can of > worms going down that path where the language starts trying to protect the > programmer from himself with all kinds of visibility options for methods and > classes. > > This leads to things like csharp and java's final/sealed classes where the > author of a class decides all future uses of the class. I prefer a language > to enable me, not restrict me. I don't want the author of a class deciding > for me how I might decide to use that class in the future. If the fragile > base class problem is the price, then I'm happy to pay it. So you are lamenting loss of encapsulation (a restrictive feature) in the first paragraph, and decrying loss of freedom to restrictive features in the second. Come on, pick one. If you don't want the author of a class deciding how you might decide to use it, how can you put up with him deciding what instance variables are off-limits and have no public accessors? Indeed what I had in mind were Newspeak-style access modifiers combined with message-based slot access. Their combination in fact improves encapsulation. And no, they don't lead to final classes. Cheers, --Vassili |
Btw, regarding instance variables:
i just stepped on error, when tried to add an instance variable in superclass while variable with that name already exists in a subclass. Note, that adding non-conflicting variable name to an existing class can't be an error. But because we need to recompile subclasses, we should scan all subclasses to detect potential naming duplication. >From user's perspective it looks like he unable to alter a base class without consulting with subclasses. And this is awfully wrong , of course :) -- Best regards, Igor Stasenko AKA sig. |
In reply to this post by Andreas.Raab
On Wed, Nov 26, 2008 at 09:06:16AM -0800, Andreas Raab wrote:
> Matthew Fulmer wrote: > > The syntax to do that is: > > > > ed := SystemEditor new. > > (ed at: #Morph) addInstVarName: #foo. > > ed commitWithProgress. > > > > Adding an instance variable to Morph used to work, but now it > > runs out of memory :P > > This doesn't seem to work. If I do something a little simpler: > > ed := SystemEditor new. > (ed at: #SimpleButtonMorph) addInstVarName: #foo. > ed commitWithProgress. > > it completes but subinstances of SimpleButtonMorph are not correctly > migrated. Try inspecting foo in "IconicButton someInstance" or in > "UpdatingSimpleButtonMorph someInstance". I don't see any incorrect migration of the ivar layout, but I did find out that the methods aren't being recompiled. I fixed this in 161. -- Matthew Fulmer -- http://mtfulmer.wordpress.com/ |
Free forum by Nabble | Edit this page |