[squeak-dev] Instance variable access in superclasses.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
76 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

Vassili Bykov-2
On Tue, Nov 25, 2008 at 7:19 PM, Greg A. Woods; Planix, Inc.
<[hidden email]> wrote:
> An object shouldn't have to use accessor methods to get at its own internal
> state, no matter where in the class hierarchy its state may be defined.
>  "super" is only needed to get around explicit re-definitions done by the
> subclass.

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

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

Greg A. Woods; Planix, Inc.

On 25-Nov-2008, at 10:58 PM, Vassili Bykov wrote:
>
> 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.

If my memory isn't failing me too much I seem to remember going to a  
talk about a dozen years ago by Adele Goldberg where she talked about  
the need to form contracts between producers and consumers of class  
definitions.

--
                                        Greg A. Woods; Planix, Inc.
                                        <[hidden email]>




PGP.sig (193 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

Igor Stasenko
In reply to this post by Greg A. Woods; Planix, Inc.
2008/11/26 Greg A. Woods; Planix, Inc. <[hidden email]>:

>
> On 25-Nov-2008, at 10: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_.
>
> Well when you're defining the behaviour of objects in an OO system there's
> not really any difference between "specialization" and "expansion" -- the
> subclass is _adding_ changes to the definitions given in the superclass.
>  Perhaps the changes will over-ride a behaviour in the superclass, or modify
> it in some way, but fundamentally a subclass is always adding something to
> the superclass in order to create the new subclass it defines.
>

No, specialization and expansion having really different meanings, if
you consider a class, like SmallInteger.
Following your understanding, one may want to expand a SmallInteger
class by subclassing it and providing additional behavior.
Following my understanding, SmallInteger class is highly specialized
class, up to the point that its impossible to specialize it further.

> Or to paraphrase the Blue Book, allowing intersection in class membership is
> the basic mechanism used to allow code sharing between class descriptions.
>  Smalltalk-80 of course doesn't allow multiple inheritance, just plain
> subclassing.
>
>> If you look from a user's point of view (outside a class), you could
>> only send a messages to it. So, for you, as for user its not relevant
>> where an object holds its state - you only interested in its
>> behavior/interface.
>
> You don't send messages to a class -- you send messages to objects which are
> derived from a class, i.e. which follow the behaviours defined by the class.
>
>> As for subclass - a subclass interested in inheriting same interface
>> as base class. Inheriting a state information having a little
>> importance, its just an implementation detail for outside user of
>> class, because anyways he unable to operate with this state directly.
>
> Classes don't have state -- objects have state.  An object which has been
> derived from a subclass gains definitions about its state from _all_ of the
> classes in the class hierarchy which the subclass belongs to.
>
Of course i know it. Just a small(talk) correction: classes are
objects as well and having state as well.

> At least that's how I understand things in the Smalltalk way of defining
> classes and instantiating objects.

>From "The Early History of Smalltalk" by Alan Kay

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?

>
> --
>                                        Greg A. Woods; Planix, Inc.
>                                        <[hidden email]>
>




--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

Tapple Gao
In reply to this post by Andreas.Raab
On Tue, Nov 25, 2008 at 03:45:09PM -0800, Andreas Raab wrote:

> Matthew Fulmer wrote:
> > On Wed, Nov 26, 2008 at 12:13:14AM +0200, Igor Stasenko wrote:
> >> IMO, it is better to recompile things all the way down, rather than
> >> bother with such complexity which gives no real benefits except
> >> compiling time.
> >
> > Or switch to SystemEditor, which can recompile classes 6-8x
> > faster than ClassBuilder.
>
> Really? I'm somewhat surprised to hear that. It means that either most
> of the time in recompilation doesn't go where I think it goes or that
> SystemEditor does things very differently from ClassBuilder. Either way
> I always take a 6x-8x speedup when I can get one - where do I find
> SystemEditor to run a few benchmarks against it?

Most of the time recompiling a class is not in the compiler. It
is in the three full image scans necessary to swap all object
instances. All three are within ClassBuilder >> update:to:

1. allInstances in ClassDescription >> updateInstancesFrom:
2. elementsExchangeIdentityWith: in ClassDescription >>
   updateInstancesFrom:to:isMeta:
3. becomeForward: or elementsForwardIdentityTo: in
   ClassBuilder >> update:to:

ClassBuilder thus does 3n full memory scans (where n is the
number of classes to recompile)

SystemEditor does n + 2 full memory scans. It does the
allInstances search once per class, then groups all the becomes
into two becomes at the end of the commit (which is most of the
reason why SystemEditor is truly atomic). I've tried to collapse
the n allInstance scans into one, but have been unable so far to
do it without crashing the VM. I think one should be able to
compile any number of classes with just two memory scans (one to
find all instances, one to becomeForward: them)

The best way to benchmark SystemEditor is to get Monticello 1.6,
which is already hooked up to use SystemEditor for all its
loading needs. Run the following to get MC1.6:

HttpSocket httpFileIn: 'installer.pbwiki.org/f/mc15.st'.
Installer install: 'Monticello16-Beta'

Beware: SystemEditor cannot yet handle packages with Traits or
packages that have Tweak classes. I'm working on it.

For some more info on SystemEditor, see
http://installer.pbwiki.org/SystemEditor
http://installer.pbwiki.org/Monticello16-Beta

I havn't put any SystemEditor speed data on the wiki yet.
They'll be more documentation as I push to get Monticello 1.6
into a final release, which should be in about two months

--
Matthew Fulmer -- http://mtfulmer.wordpress.com/

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

keith1y
In reply to this post by Andreas.Raab
Andreas Raab wrote:

> Matthew Fulmer wrote:
>> On Wed, Nov 26, 2008 at 12:13:14AM +0200, Igor Stasenko wrote:
>>> IMO, it is better to recompile things all the way down, rather than
>>> bother with such complexity which gives no real benefits except
>>> compiling time.
>>
>> Or switch to SystemEditor, which can recompile classes 6-8x
>> faster than ClassBuilder.
>
> Really? I'm somewhat surprised to hear that. It means that either most
> of the time in recompilation doesn't go where I think it goes or that
> SystemEditor does things very differently from ClassBuilder. Either
> way I always take a 6x-8x speedup when I can get one - where do I find
> SystemEditor to run a few benchmarks against it?
>
> Cheers,
>   - Andreas
Installer squeaksource project: 'SystemEditor'; install:
'SystemEditor-Core'; install: 'SystemEditor-Squeak'.

http://installer.pbwiki.com/SystemEditor

I just added it to the development package universe, along with
Monticello15 and Monticello16. MC1.6 uses SystemEditor and I love it!

Keith

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

jgfoster
In reply to this post by Igor Stasenko

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

Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: Instance variable access in superclasses.

Andreas.Raab
In reply to this post by keith1y
Keith Hodges wrote:
> Installer squeaksource project: 'SystemEditor'; install:
> 'SystemEditor-Core'; install: 'SystemEditor-Squeak'.
>
> http://installer.pbwiki.com/SystemEditor
>
> I just added it to the development package universe, along with
> Monticello15 and Monticello16. MC1.6 uses SystemEditor and I love it!

Thanks. And do you by any chance have a simple example, say adding an
iVar to an existing class?

Cheers,
   - Andreas

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

Igor Stasenko
In reply to this post by jgfoster
2008/11/26 James Foster <[hidden email]>:

>
> 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).
>

Good example.
Right , Square looks more specialized. And since it always having
width == height , it looks like an error to keep a redundant state.
So, i don't see much problem.
We can define a common ancestor, like TwoDimensionalObject, having
#width, #height abstract accessors.
And then, define two subclasses Square and Rectangle which have
different specialization of TwoDimensionalObject because require a
different number of slots for storing data.

There are many examples of such approach.
Consider a Number - Float - BigInteger classes. Float and BigInteger
sharing common behavior which comes from Number but storage format is
completely different.
Same is for String - ByteString and WideString.
This actually shows that inheritance is not relevant with objects format.

> James
>
>

--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

[squeak-dev] SystemEditor (was: Re: Instance variable access in superclasses)

Andreas.Raab
In reply to this post by Tapple Gao
Matthew Fulmer wrote:
> Most of the time recompiling a class is not in the compiler. It
> is in the three full image scans necessary to swap all object
> instances. All three are within ClassBuilder >> update:to:

That assumes that the majority of time being spent in class reshapes is
spent in these memory scans. This certainly didn't used to be the case -
the majority of time when dealing with real class hierarchies like
Morphic or MVC was spent recompiling (i.e., parsing). Since the compiler
is still the same I'm surprised you see that much of a speedup. Unless
SystemEditor doesn't recompile but rather relink (update ivar mapping
only without parsing)? This would certainly give it a serious boost.

> 1. allInstances in ClassDescription >> updateInstancesFrom:
> 2. elementsExchangeIdentityWith: in ClassDescription >>
>    updateInstancesFrom:to:isMeta:
> 3. becomeForward: or elementsForwardIdentityTo: in
>    ClassBuilder >> update:to:
>
> ClassBuilder thus does 3n full memory scans (where n is the
> number of classes to recompile)

Yes. Partly to preserve space (since you only need to deal with all the
instance of a single class instead of an entire class hierarchy like
Morphic). The other reason is ... ClassBuilder>>update:to: which is one
nasty set of constraints that it's hard to believe (and even harder to
get right).

> SystemEditor does n + 2 full memory scans. It does the
> allInstances search once per class, then groups all the becomes
> into two becomes at the end of the commit (which is most of the
> reason why SystemEditor is truly atomic). I've tried to collapse
> the n allInstance scans into one, but have been unable so far to
> do it without crashing the VM. I think one should be able to
> compile any number of classes with just two memory scans (one to
> find all instances, one to becomeForward: them)

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 ;-)

I'm looking forward to test-drive SystemEditor a little more.

Cheers,
   - Andreas

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

Trygve
In reply to this post by Igor Stasenko


On 26.11.2008 01:57, Igor Stasenko wrote:
I like the idea of hiding the state/storage specific details from eyes
of subclasses.
It makes irrelevant, in what format or where particular object holds its state.
As long as you providing messages to access it, it could be anything.

  

This "hiding" comes at a cost. Object state can only be accessed from within the object itself. Accessor methods are public, they can be accessed from anywhere.
--Trygve

--
--

Trygve Reenskaug       mailto: [hidden email]

Morgedalsvn. 5A         http://heim.ifi.uio.no/~trygver

N-0378 Oslo               Tel: (+47) 22 49 57 27

Norway



Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

Trygve
In reply to this post by Igor Stasenko


On 26.11.2008 05:32, Igor Stasenko wrote:

Of course i know it. Just a small(talk) correction: classes are
objects as well and having state as well.


  
>From "The Early History of Smalltalk" by Alan Kay

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. In a Squeak image, everything *IS REPRESENTED* by an object. I represent a cat by an object,  but that doesn't magically transform the purring cat into a Squeak object. I *REPRESENT* a class by an object, but it is confusing the issue to remove the distinction between the essence of a class and its representation as an object. Many a discussion has gone astray through this confusion. (Have you ever heard anyone say "class A send a message to class B" when they mean "an instance of class A send a message to an instance of class B"? )

--Trygve
--
--

Trygve Reenskaug       mailto: [hidden email]

Morgedalsvn. 5A         http://heim.ifi.uio.no/~trygver

N-0378 Oslo               Tel: (+47) 22 49 57 27

Norway



Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

Igor Stasenko
2008/11/26 Trygve Reenskaug <[hidden email]>:

>
>
> On 26.11.2008 05:32, Igor Stasenko wrote:
>
> Of course i know it. Just a small(talk) correction: classes are
> objects as well and having state as well.
>
>
> >From "The Early History of Smalltalk" by Alan Kay
>
> 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.

> In a Squeak image, everything *IS REPRESENTED* by an object. I represent a cat by an
> object,  but that doesn't magically transform the purring cat into a Squeak
> object. I *REPRESENT* a class by an object, but it is confusing the issue to
> remove the distinction between the essence of a class and its representation
> as an object. Many a discussion has gone astray through this confusion.

To be fair , i was confused at first time , trying to understand how
basic class structure is defined and what connection between
Object, Behavior, Class and Metaclass. Still, i wrote a bootstrap code
in a few days, and it worked :)
Its hard to express such structure in words. But if you doing it step
by step - its not that hard.

>From VM's point of view: a class is a structure which holds a method
dictionary in one of its slots, so VM could perform method lookup.
Yes, its quite special entity, and you can't freely change it. But
this not makes it a less object than anything else. Its just another
kind of specialization :)

> (Have you ever heard anyone say "class A send a message to class B" when
> they mean "an instance of class A send a message to an instance of class B"?
> )

Never heard of it. People who saying like this, either don't
understand how message passing working , or its just a phrase taken
out from context, where everyone understand that speaker having
something concrete (instances or class objects themselves) in mind.
I can imagine smalltalk without inheritance, and even without classes
(in Squeak's form). But not without message passing.

>
> --Trygve
> --
>
> Trygve Reenskaug       mailto: [hidden email]
>
> Morgedalsvn. 5A         http://heim.ifi.uio.no/~trygver
>
> N-0378 Oslo               Tel: (+47) 22 49 57 27
>
> Norway
>
>

--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

Tapple Gao
In reply to this post by Andreas.Raab
On Tue, Nov 25, 2008 at 10:47:12PM -0800, Andreas Raab wrote:

> Keith Hodges wrote:
> > Installer squeaksource project: 'SystemEditor'; install:
> > 'SystemEditor-Core'; install: 'SystemEditor-Squeak'.
> >
> > http://installer.pbwiki.com/SystemEditor
> >
> > I just added it to the development package universe, along with
> > Monticello15 and Monticello16. MC1.6 uses SystemEditor and I love it!
>
> Thanks. And do you by any chance have a simple example, say adding an
> iVar to an existing class?

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

--
Matthew Fulmer -- http://mtfulmer.wordpress.com/

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] SystemEditor (was: Re: Instance variable access in superclasses)

Colin Putney
In reply to this post by Andreas.Raab

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

Reply | Threaded
Open this post in threaded view
|

The Gospel of Alan (was Re: [squeak-dev] Re: Instance variable access in superclasses)

Bert Freudenberg
In reply to this post by Igor Stasenko
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 ;)

- Bert -



Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Using SystemEditor (was: Re: Instance variable access in superclasses.)

Andreas.Raab
In reply to this post by Tapple Gao
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".

Cheers,
   - Andreas

Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Kay's Little Blue Book, or, Let's Just Do It! (was Re: The Gospel of Alan)

Tony Garnock-Jones-2
In reply to this post by Bert Freudenberg
(Attention-conservation notice: the penultimate paragraph is most
important.)

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! :-)

>From reading the old and new papers out there, and the interviews, and
the new stuff VPRI are up to, I'm getting the impression that it's very
difficult to understand the *subtlety* of the ideas that led to
Smalltalk[1] -- which leads people (like me) to mistakenly concentrate
on the artifacts (i.e. Smalltalk) and their properties, when the
motivation for constructing the artifacts is much more important.

Smalltalk is much more interesting when viewed as almost a throwaway
experiment in realising some of these more abstract background ideas.

Part of the problem, I think, is that the ideas aren't just subtle,
they're also *alien* to the vast majority of programmers out there:
hobbyists, academics, and those in industry alike. Very hard to get
one's head around. (Compare with Dijkstra's opinion of BASIC.)

***** I'd really appreciate an extended essay -- a textbook? a
manifesto? -- from those who properly grok it (i.e. Alan and those at
VPRI), aimed at helping out those who'd like to: a kind of little-step
by little-step introduction to weaning people off their current mindset
and helping them explore the subtleties of the new way of looking at
things. Something akin in spirit, perhaps, to Drexler's Engines of
Creation. *****

It'd be useful not just to me, but for all those I (and no doubt other
readers of this list) run across who can't understand why
Smalltalk-the-artifact is simultaneously a great improvement on its
successors and a system unsuitable for serious use.

Regards,
  Tony

[1] such as, from http://www.mprove.de/diplom/gui/Kay72a.pdf, the view
of the duality between data and function through the lens of process,
and from the newer VPRI material the "particles and fields" metaphor of
distributed systems.


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

Greg A. Woods; Planix, Inc.
In reply to this post by Igor Stasenko

On 25-Nov-2008, at 11:32 PM, Igor Stasenko wrote:

> 2008/11/26 Greg A. Woods; Planix, Inc. <[hidden email]>:
>>
>> On 25-Nov-2008, at 10: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_.
>>
>> Well when you're defining the behaviour of objects in an OO system  
>> there's
>> not really any difference between "specialization" and "expansion"  
>> -- the
>> subclass is _adding_ changes to the definitions given in the  
>> superclass.
>> Perhaps the changes will over-ride a behaviour in the superclass,  
>> or modify
>> it in some way, but fundamentally a subclass is always adding  
>> something to
>> the superclass in order to create the new subclass it defines.
>>
>
> No, specialization and expansion having really different meanings, if
> you consider a class, like SmallInteger.
> Following your understanding, one may want to expand a SmallInteger
> class by subclassing it and providing additional behavior.
> Following my understanding, SmallInteger class is highly specialized
> class, up to the point that its impossible to specialize it further.
What you say is true, but irrelevant to my point.

If you want to create a more specialized subclass of SmallInteger you  
must _add_ code by defining that new subclass.  A subclass always, by  
definition, adds new additional code to the class it inherits from.

Here I'm looking at the actual process of defining a subclass.  
Literally and figuratively.  In Smalltalk-80 a subclass always adds  
code to the class it inherits from, regardless of whether the intent  
is to create a specialized form of the superclass or to create an  
expanded form of the superclass.

Sorry, I probably should have been more explicit in the first place  
about the perspective I'm seeing this issue from.


> Of course i know it. Just a small(talk) correction: classes are
> objects as well and having state as well.

Sure, but that's just a feature of the implementation that comes out  
of the goal to have _everything_ be an object.  That's just the way  
the system describes itself to itself to keep the VM small and simple  
and primitive and perhaps also in some minor way to try to express the  
system within itself in the same way lisp does.  It does help show  
that the design is complete and elegant too of course, and in many  
ways it perhaps makes the implementation easier to design, work with,  
and even use.


>> From "The Early History of Smalltalk" by Alan Kay
>
> 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?

Indeed you don't find anything about inheritance there of course.  
It's not relevant in that context.

Inheritance is an additional feature of Classes, one which adds to an  
OO system.  There were, IIRC, earlier Smalltalks which didn't have  
inheritance, but Smalltalk-80 does, in the form of subclassing.  To  
quote directly from the blue book (p. 56):

        "Lack of intersection in class membership is a limitation on design  
in an object-oriented system since it does not allow any sharing  
between class descriptions.  [[....]]  If class memberships are not  
allowed to overlap, this type of partial similarity between two object  
cannot be guaranteed by the system."

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).

The price you pay of course for the assistance of the system in this  
way is that maintainers of the superclass(es) must now take into  
account the needs of subclass(es), both existing and potential future  
ones too; eg. instance variables (and everything else) defined in the  
superclass are also actually part of the subclass.  TANSTAAFL

Subclassing is just a way of appearing to dynamically copy code and  
then allowing for controlled ways to modify it and add to it.  Again  
the free lunch is taken away by the need for the current  
implementation to recompile subclasses and potentially also fiddle  
with all object instances of those subclasses when certain attributes  
(such as instance variables) are changed in the superclass definition.

This essay is interesting in this context, and perhaps even slightly  
relevant to the whole thread:

        "The Dreaded Super" by Kent Beck
        first published June 1992 in Smalltalk Report
        http://books.google.ca/books?id=Y7FwNB4GV4EC&pg=PA81

--
                                        Greg A. Woods; Planix, Inc.
                                        <[hidden email]>




PGP.sig (193 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

Eliot Miranda-2


On Wed, Nov 26, 2008 at 10:22 AM, Greg A. Woods; Planix, Inc. <[hidden email]> wrote:

On 25-Nov-2008, at 11:32 PM, Igor Stasenko wrote:

2008/11/26 Greg A. Woods; Planix, Inc. <[hidden email]>:

On 25-Nov-2008, at 10: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_.

Well when you're defining the behaviour of objects in an OO system there's
not really any difference between "specialization" and "expansion" -- the
subclass is _adding_ changes to the definitions given in the superclass.
Perhaps the changes will over-ride a behaviour in the superclass, or modify
it in some way, but fundamentally a subclass is always adding something to
the superclass in order to create the new subclass it defines.


No, specialization and expansion having really different meanings, if
you consider a class, like SmallInteger.
Following your understanding, one may want to expand a SmallInteger
class by subclassing it and providing additional behavior.
Following my understanding, SmallInteger class is highly specialized
class, up to the point that its impossible to specialize it further.

What you say is true, but irrelevant to my point.

If you want to create a more specialized subclass of SmallInteger you must _add_ code by defining that new subclass.  A subclass always, by definition, adds new additional code to the class it inherits from.

Then choose a different class than SmallInteger to make your point.  SmallInteger is rather special, an immediate class whose instances are represented specially by encoding their value in an object pointer, so that a reference to a SmallInteger *is* the SmallInteger.  In Squeak SmallInteger is the only such class.  Subclasses of SmallInteger by necessity are normal objects so that when any of the inherited behaviour is used nonsense results because the subclass instance's normal pointer is interpreted as a SmallInteger.

Make your point with any other class.  Using SmallInteger will simply create cognitive dissonance and defocus the conversation.





Here I'm looking at the actual process of defining a subclass.  Literally and figuratively.  In Smalltalk-80 a subclass always adds code to the class it inherits from, regardless of whether the intent is to create a specialized form of the superclass or to create an expanded form of the superclass.

Sorry, I probably should have been more explicit in the first place about the perspective I'm seeing this issue from.


Of course i know it. Just a small(talk) correction: classes are
objects as well and having state as well.

Sure, but that's just a feature of the implementation that comes out of the goal to have _everything_ be an object.  That's just the way the system describes itself to itself to keep the VM small and simple and primitive and perhaps also in some minor way to try to express the system within itself in the same way lisp does.  It does help show that the design is complete and elegant too of course, and in many ways it perhaps makes the implementation easier to design, work with, and even use.


>From "The Early History of Smalltalk" by Alan Kay

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?


Indeed you don't find anything about inheritance there of course.  It's not relevant in that context.

Inheritance is an additional feature of Classes, one which adds to an OO system.  There were, IIRC, earlier Smalltalks which didn't have inheritance, but Smalltalk-80 does, in the form of subclassing.  To quote directly from the blue book (p. 56):

       "Lack of intersection in class membership is a limitation on design in an object-oriented system since it does not allow any sharing between class descriptions.  [[....]]  If class memberships are not allowed to overlap, this type of partial similarity between two object cannot be guaranteed by the system."

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).

The price you pay of course for the assistance of the system in this way is that maintainers of the superclass(es) must now take into account the needs of subclass(es), both existing and potential future ones too; eg. instance variables (and everything else) defined in the superclass are also actually part of the subclass.  TANSTAAFL

Subclassing is just a way of appearing to dynamically copy code and then allowing for controlled ways to modify it and add to it.  Again the free lunch is taken away by the need for the current implementation to recompile subclasses and potentially also fiddle with all object instances of those subclasses when certain attributes (such as instance variables) are changed in the superclass definition.

This essay is interesting in this context, and perhaps even slightly relevant to the whole thread:

       "The Dreaded Super" by Kent Beck
       first published June 1992 in Smalltalk Report
       http://books.google.ca/books?id=Y7FwNB4GV4EC&pg=PA81

--
                                       Greg A. Woods; Planix, Inc.
                                       <[hidden email]>







Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: Instance variable access in superclasses.

Tony Garnock-Jones-2
In reply to this post by Greg A. Woods; Planix, Inc.
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?

1234