Re: [Newbies] new vs. initialize

2008-12-09 Thread Tim Johnson


On Dec 8, 2008, at 8:56 PM, Greg A. Woods; Planix, Inc. wrote:

Initially though this recommendation didn't make any sense to me  
because I didn't know how the implementation of #new in Behaviour is  
different from strict Smalltalk-80 as I understand it.  I.e.  
originally in Smalltalk-80 #new did not also send #initialize, but  
now in Squeak it does.


This recent (!) change to auto-initialize puzzles me as well.  So much  
existing code was written with the opposite case being true, that it  
seems so risky to change!  To diverge from the ST-80 standard is even  
more risky, I would think.


I was convinced that this change is the one-and-only reason why  
BDFFontReader became broken.  So what else is broken now because of  
this change?  I don't know.  What human logic instigated the change?   
I also don't know.  Perhaps it makes the system more accessible or  
consistent for newbies?


It was because of changes like this that I kind of threw in the hat on  
Squeak for a while, after 3.8 and before 3.10.  It seemed all these  
weird changes that  seemed illogical to me (a relative newcomer to  
Smalltalk) were being made, while existing problems were not being  
addressed.


- TimJ

___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


[Newbies] new vs. initialize

2008-12-08 Thread Greg A. Woods; Planix, Inc.
So this problem I posted on squeak-dev about BDFFontReader and how it  
has its own #new class method to create new instances of itself, but  
in doing so failed to also send an #initialize message to each new  
instance and thus when it was actually used an instance variable was  
left as nil when it should not have been.


One recommendation was to simply remove the #new method and thus  
default to the superclass #new which, if I'm not mistaken, would then  
result in #new from Behaviour to be invoked and that one does also  
send #initialize to self.


I think, IIUC, this recommendation only makes sense because  
BDFFontReader is a direct subclass of Object.


Initially though this recommendation didn't make any sense to me  
because I didn't know how the implementation of #new in Behaviour is  
different from strict Smalltalk-80 as I understand it.  I.e.  
originally in Smalltalk-80 #new did not also send #initialize, but now  
in Squeak it does.


Just for fun I did a search for senders of #basicNew and I found quite  
a few which are from #new methods in classes which subclass directly  
from Object and which are in classes that also define their own  
#initialize method.  The curious bit is how some of these #new methods  
do send #initialize, but not all.  I'm guessing some that don't are  
for abstract classes, but is it true that all are?


Now I read on the WWW that the added sending of #initialize from  
Behaviournew was added in 3.9.


Unfortunately whomever actually did the change failed to document the  
important differences here, and why!  How is it that with such a  
wonderful system for documenting code we still end up with totally  
missing documentation?  I've now gone on a huge wild goose chase  
because of this.  How many others who have not kept track of how  
Squeak is evolving away from other Smalltalk-80 implementations will  
waste similar amounts of time?


I'm guessing that some of the now unnecessary #new methods are simply  
still not cleaned up since then?  If so, why not?  They're easy enough  
to find!


Also, doesn't this still create an _enormous_ portability problem with  
other Smalltalks?


(BTW, I'm not even sure I buy into any of the other arguments for  
having default invocation of #initialize, i.e. those beyond the  
blatant incompatibility with what seems to be _all_ other  
implementations and _all_ existing documentation about the  
fundamentals of Smalltalk.  I remember naively thinking this would be  
a good idea way back in the early 80's when I last spent any amount of  
time fiddling with Smalltalk, and I also seem to remember all the wise  
gurus around me quietly patting me on the head and telling me that no,  
such a change would not be welcome, and I should just learn to do  
things explicitly like they should be done.)


--
Greg A. Woods; Planix, Inc.
[EMAIL PROTECTED]



PGP.sig
Description: This is a digitally signed message part
___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners