Unintuitive behavior of class-side initialize

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

Unintuitive behavior of class-side initialize

webwarrior
As class is just an object in Smalltalk, it would be reasonable to believe that #initialize message is always sent to class on creation.

However, that's not true. It is only sent to classes that redefine #initialize. Also sending super initialize may lead to problems.

None of these is mentioned in documentation (I assume Pahro By Example is the official one). It only says that #initialize is sent when class is loaded into memory.

I think either this behavior should be made more consistent, or excplicitly mentioned in the docs.
Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

Mariano Martinez Peck



On Wed, Aug 27, 2014 at 8:22 AM, webwarrior <[hidden email]> wrote:
As class is just an object in Smalltalk, it would be reasonable to believe
that #initialize message is always sent to class on creation.

However, that's not true. It is only sent to classes that redefine
#initialize. Also sending super initialize may lead to problems.


Ohhh yes. There is always a time for every Smalltalkers where you discover that doing super for class side initialize is not a good idea.
 
None of these is mentioned in documentation (I assume Pahro By Example is
the official one). It only says that #initialize is sent when class is
loaded into memory.

I think either this behavior should be made more consistent, or excplicitly
mentioned in the docs.


+1 to the documentation 
 



--
View this message in context: http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




--
Mariano
http://marianopeck.wordpress.com
Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

kilon.alios
I will be adding an "Introduction to Object Orientation" chapter to the new updated Pharo By Example online book, so I will add this to the chapter. The chapter will target people not familiar with Object Orientation and people new to coding. Its not an immediate target but it will happen till the end of the year.   


On Wed, Aug 27, 2014 at 3:44 PM, Mariano Martinez Peck <[hidden email]> wrote:



On Wed, Aug 27, 2014 at 8:22 AM, webwarrior <[hidden email]> wrote:
As class is just an object in Smalltalk, it would be reasonable to believe
that #initialize message is always sent to class on creation.

However, that's not true. It is only sent to classes that redefine
#initialize. Also sending super initialize may lead to problems.


Ohhh yes. There is always a time for every Smalltalkers where you discover that doing super for class side initialize is not a good idea.
 
None of these is mentioned in documentation (I assume Pahro By Example is
the official one). It only says that #initialize is sent when class is
loaded into memory.

I think either this behavior should be made more consistent, or excplicitly
mentioned in the docs.


+1 to the documentation 
 



--
View this message in context: http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




--
Mariano
http://marianopeck.wordpress.com

Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

webwarrior
This is not something fundamental to OOP, just specific to Pharo or
Smalltalk.

Take for example Python. It has similar object model (objects, classes,
metaclasses). Every time class is defined (either by class keyword, or
by type() function, or by calling a metaclass), its metaclass' __init__
method is called.
Usually you don't need to redefine metaclass' __init__ method, because
class attributes are initialized in class definition. But when you do,
it works as expected.

27.08.2014 15:50, kilon.alios [via Smalltalk] написав(ла):

> I will be adding an "Introduction to Object Orientation" chapter to the
> new updated Pharo By Example online book, so I will add this to the
> chapter. The chapter will target people not familiar with Object
> Orientation and people new to coding. Its not an immediate target but it
> will happen till the end of the year.
>
>
> On Wed, Aug 27, 2014 at 3:44 PM, Mariano Martinez Peck <[hidden email]
> </user/SendEmail.jtp?type=node&node=4775051&i=0>> wrote:
>
>
>
>
>     On Wed, Aug 27, 2014 at 8:22 AM, webwarrior <[hidden email]
>     </user/SendEmail.jtp?type=node&node=4775051&i=1>> wrote:
>
>         As class is just an object in Smalltalk, it would be reasonable
>         to believe
>         that #initialize message is always sent to class on creation.
>
>         However, that's not true. It is only sent to classes that redefine
>         #initialize. Also sending super initialize may lead to problems.
>
>
>     Ohhh yes. There is always a time for every Smalltalkers where you
>     discover that doing super for class side initialize is not a good idea.
>     Here was my time:
>     http://forum.world.st/super-initialize-is-not-a-good-idea-for-Behaviors-td3086162.html
>
>         None of these is mentioned in documentation (I assume Pahro By
>         Example is
>         the official one). It only says that #initialize is sent when
>         class is
>         loaded into memory.
>
>         I think either this behavior should be made more consistent, or
>         excplicitly
>         mentioned in the docs.
>
>
>
>     +1 to the documentation
>
>
>
>
>         --
>         View this message in context:
>         http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042.html
>         Sent from the Pharo Smalltalk Users mailing list archive at
>         Nabble.com.
>
>
>
>
>     --
>     Mariano
>     http://marianopeck.wordpress.com
>
>
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042p4775051.html
>
> To unsubscribe from Unintuitive behavior of class-side initialize, click
> here
> <
> NAML
> <
http://forum.world.st/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>

Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

kilon.alios
ok officially I am confused are we talking about initialise at the instance side or class side  (metaclass) side ?

I am  a python coder myself but I have not done any metaprogramming . 

If it is a metaprogramming thing then yes it wont go inside my intro chapter since this is advanced topic and metaprogramming is already covered by PBE on a separate chapter so that can be added there. Since I am not experienced with metaprogramming it would be better if people experienced with Pharo and metaprogramming would write the documentation .


On Wed, Aug 27, 2014 at 6:16 PM, webwarrior <[hidden email]> wrote:
This is not something fundamental to OOP, just specific to Pharo or
Smalltalk.

Take for example Python. It has similar object model (objects, classes,
metaclasses). Every time class is defined (either by class keyword, or
by type() function, or by calling a metaclass), its metaclass' __init__
method is called.
Usually you don't need to redefine metaclass' __init__ method, because
class attributes are initialized in class definition. But when you do,
it works as expected.

27.08.2014 15:50, kilon.alios [via Smalltalk] написав(ла):

> I will be adding an "Introduction to Object Orientation" chapter to the
> new updated Pharo By Example online book, so I will add this to the
> chapter. The chapter will target people not familiar with Object
> Orientation and people new to coding. Its not an immediate target but it
> will happen till the end of the year.
>
>
> On Wed, Aug 27, 2014 at 3:44 PM, Mariano Martinez Peck <[hidden email]
> </user/SendEmail.jtp?type=node&node=4775051&i=0>> wrote:
>
>
>
>
>     On Wed, Aug 27, 2014 at 8:22 AM, webwarrior <[hidden email]
>     </user/SendEmail.jtp?type=node&node=4775051&i=1>> wrote:

>
>         As class is just an object in Smalltalk, it would be reasonable
>         to believe
>         that #initialize message is always sent to class on creation.
>
>         However, that's not true. It is only sent to classes that redefine
>         #initialize. Also sending super initialize may lead to problems.
>
>
>     Ohhh yes. There is always a time for every Smalltalkers where you
>     discover that doing super for class side initialize is not a good idea.
>     Here was my time:
>     http://forum.world.st/super-initialize-is-not-a-good-idea-for-Behaviors-td3086162.html
>

>         None of these is mentioned in documentation (I assume Pahro By
>         Example is
>         the official one). It only says that #initialize is sent when
>         class is
>         loaded into memory.
>
>         I think either this behavior should be made more consistent, or
>         excplicitly
>         mentioned in the docs.
>
>
>
>     +1 to the documentation
>
>
>
>
>         --
>         View this message in context:
>         http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042.html
>         Sent from the Pharo Smalltalk Users mailing list archive at

>         Nabble.com.
>
>
>
>
>     --
>     Mariano
>     http://marianopeck.wordpress.com
>
>
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042p4775051.html
>
> To unsubscribe from Unintuitive behavior of class-side initialize, click
> here
> <
> NAML
> <
http://forum.world.st/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



View this message in context: Re: Unintuitive behavior of class-side initialize

Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

webwarrior
class-side initialize.

I don't think it can be considered a metaprogramming in Smalltalk.

In Python, yes, messing with metaclass is metaprogramming. But things
are a bit different there and metaclasses are very rarely used [explicitly].

27.08.2014 19:05, kilon.alios [via Smalltalk] написав(ла):

> ok officially I am confused are we talking about initialise at the
> instance side or class side  (metaclass) side ?
>
> I am  a python coder myself but I have not done any metaprogramming .
>
> If it is a metaprogramming thing then yes it wont go inside my intro
> chapter since this is advanced topic and metaprogramming is already
> covered by PBE on a separate chapter so that can be added there. Since I
> am not experienced with metaprogramming it would be better if people
> experienced with Pharo and metaprogramming would write the documentation .

Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

philippeback

Yeah don't do super initialize unless you know why on the class side.

That being said class side initialize is pretty cool when loading new packages and setting everything up automagically.

Phil

Le 27 août 2014 18:33, "webwarrior" <[hidden email]> a écrit :
class-side initialize.

I don't think it can be considered a metaprogramming in Smalltalk.

In Python, yes, messing with metaclass is metaprogramming. But things
are a bit different there and metaclasses are very rarely used [explicitly].

27.08.2014 19:05, kilon.alios [via Smalltalk] написав(ла):

> ok officially I am confused are we talking about initialise at the
> instance side or class side  (metaclass) side ?
>
> I am  a python coder myself but I have not done any metaprogramming .
>
> If it is a metaprogramming thing then yes it wont go inside my intro
> chapter since this is advanced topic and metaprogramming is already
> covered by PBE on a separate chapter so that can be added there. Since I
> am not experienced with metaprogramming it would be better if people
> experienced with Pharo and metaprogramming would write the documentation .


View this message in context: Re: Unintuitive behavior of class-side initialize
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

kilon.alios
In reply to this post by webwarrior
yeah python does not need initialisation for class variables like it does for instance variables, but then same applies for instance variables, for example you can add instance variables and even instance method after the instance is created , pharo does something similar too. 

Well OOP is a deep subject and this is an advanced topic that I would not want to put in an introductionary chapter.

I had issues with initialise on class side recently where i was told i had to initialise the class myself instead I chose to go down the ifNil route and initialise my class variables inside other methods.  This way I avoided the creation of an initialise method, and probably i will avoid using it in the future too. From what I see most classes (metaclasses) dont use an initialise method either. 


On Wed, Aug 27, 2014 at 7:33 PM, webwarrior <[hidden email]> wrote:
class-side initialize.

I don't think it can be considered a metaprogramming in Smalltalk.

In Python, yes, messing with metaclass is metaprogramming. But things
are a bit different there and metaclasses are very rarely used [explicitly].

27.08.2014 19:05, kilon.alios [via Smalltalk] написав(ла):

> ok officially I am confused are we talking about initialise at the
> instance side or class side  (metaclass) side ?
>
> I am  a python coder myself but I have not done any metaprogramming .
>
> If it is a metaprogramming thing then yes it wont go inside my intro
> chapter since this is advanced topic and metaprogramming is already
> covered by PBE on a separate chapter so that can be added there. Since I
> am not experienced with metaprogramming it would be better if people
> experienced with Pharo and metaprogramming would write the documentation .


View this message in context: Re: Unintuitive behavior of class-side initialize
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

webwarrior
I've also chosen ifNil route.
However, in that case you either:
- break encapsulation by providing accessors
- have to invoke initializing method in every method that uses class
instance variables or class variables

27.08.2014 20:31, kilon.alios [via Smalltalk] написав(ла):

> yeah python does not need initialisation for class variables like it
> does for instance variables, but then same applies for instance
> variables, for example you can add instance variables and even instance
> method after the instance is created , pharo does something similar too.
>
> Well OOP is a deep subject and this is an advanced topic that I would
> not want to put in an introductionary chapter.
>
> I had issues with initialise on class side recently where i was told i
> had to initialise the class myself instead I chose to go down the ifNil
> route and initialise my class variables inside other methods.  This way
> I avoided the creation of an initialise method, and probably i will
> avoid using it in the future too. From what I see most classes
> (metaclasses) dont use an initialise method either.
>
>
> On Wed, Aug 27, 2014 at 7:33 PM, webwarrior <[hidden email]
> </user/SendEmail.jtp?type=node&node=4775110&i=0>> wrote:
>
>     class-side initialize.
>
>     I don't think it can be considered a metaprogramming in Smalltalk.
>
>     In Python, yes, messing with metaclass is metaprogramming. But things
>     are a bit different there and metaclasses are very rarely used
>     [explicitly].
>
>     27.08.2014 19:05, kilon.alios [via Smalltalk] написав(ла):
>
>      > ok officially I am confused are we talking about initialise at the
>      > instance side or class side  (metaclass) side ?
>      >
>      > I am  a python coder myself but I have not done any
>     metaprogramming .
>      >
>      > If it is a metaprogramming thing then yes it wont go inside my intro
>      > chapter since this is advanced topic and metaprogramming is already
>      > covered by PBE on a separate chapter so that can be added there.
>     Since I
>      > am not experienced with metaprogramming it would be better if people
>      > experienced with Pharo and metaprogramming would write the
>     documentation .
>
>     ------------------------------------------------------------------------
>     View this message in context: Re: Unintuitive behavior of class-side
>     initialize
>     <http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042p4775103.html>
>     Sent from the Pharo Smalltalk Users mailing list archive
>     <http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html> at
>     Nabble.com.
>
>
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042p4775110.html
>
> To unsubscribe from Unintuitive behavior of class-side initialize, click
> here
> <
> NAML
> <
http://forum.world.st/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>

Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

Ben Coman
In reply to this post by webwarrior
webwarrior wrote:

> As class is just an object in Smalltalk, it would be reasonable to believe
> that #initialize message is always sent to class on creation.
>
> However, that's not true. It is only sent to classes that redefine
> #initialize. Also sending super initialize may lead to problems.
>
> None of these is mentioned in documentation (I assume Pahro By Example is
> the official one). It only says that #initialize is sent when class is
> loaded into memory.
>
> I think either this behavior should be made more consistent, or excplicitly
> mentioned in the docs.
>
>
>
> --
> View this message in context: http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>
>  
Sometimes when I type "initialize" as a new method and hit <Enter>, it
auto adds in "super initialize" as a template.  Perhaps on the class
side it should auto add a comment saying "Do not call super initialize
on the class side"

cheers -ben

Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

kilon.alios
In reply to this post by webwarrior
I assume you mean there will be an inheritance issue if I want the variables to be inherited with a default value by the subclasses, which is a valid concern. Other than that you can have accessors for it as far I know . But yeah in that case of inheritance you need some kind of initialise method. 

I have not played with class instance variables so no clue about that part.


On Wed, Aug 27, 2014 at 8:38 PM, webwarrior <[hidden email]> wrote:
I've also chosen ifNil route.
However, in that case you either:
- break encapsulation by providing accessors
- have to invoke initializing method in every method that uses class
instance variables or class variables

27.08.2014 20:31, kilon.alios [via Smalltalk] написав(ла):

> yeah python does not need initialisation for class variables like it
> does for instance variables, but then same applies for instance
> variables, for example you can add instance variables and even instance
> method after the instance is created , pharo does something similar too.
>
> Well OOP is a deep subject and this is an advanced topic that I would
> not want to put in an introductionary chapter.
>
> I had issues with initialise on class side recently where i was told i
> had to initialise the class myself instead I chose to go down the ifNil
> route and initialise my class variables inside other methods.  This way
> I avoided the creation of an initialise method, and probably i will
> avoid using it in the future too. From what I see most classes
> (metaclasses) dont use an initialise method either.
>
>
> On Wed, Aug 27, 2014 at 7:33 PM, webwarrior <[hidden email]

> </user/SendEmail.jtp?type=node&node=4775110&i=0>> wrote:
>
>     class-side initialize.
>
>     I don't think it can be considered a metaprogramming in Smalltalk.
>
>     In Python, yes, messing with metaclass is metaprogramming. But things
>     are a bit different there and metaclasses are very rarely used
>     [explicitly].
>
>     27.08.2014 19:05, kilon.alios [via Smalltalk] написав(ла):
>
>      > ok officially I am confused are we talking about initialise at the
>      > instance side or class side  (metaclass) side ?
>      >
>      > I am  a python coder myself but I have not done any
>     metaprogramming .
>      >
>      > If it is a metaprogramming thing then yes it wont go inside my intro
>      > chapter since this is advanced topic and metaprogramming is already
>      > covered by PBE on a separate chapter so that can be added there.
>     Since I
>      > am not experienced with metaprogramming it would be better if people
>      > experienced with Pharo and metaprogramming would write the
>     documentation .
>
>     ------------------------------------------------------------------------
>     View this message in context: Re: Unintuitive behavior of class-side
>     initialize
>     <http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042p4775103.html>
>     Sent from the Pharo Smalltalk Users mailing list archive
>     <http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html> at
>     Nabble.com.
>
>
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042p4775110.html



View this message in context: Re: Unintuitive behavior of class-side initialize
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

nacho
In reply to this post by kilon.alios
Kilon,
Do you have a preview version of the updated book?
I would love to see it.
Also would you consider adding some exercises will be a good addition? I think so....let me know and i guess i can merge the project i've started to the updated book.
Best
Nacho

Enviado desde Molto para iPad

I will be adding an "Introduction to Object Orientation" chapter to the new updated Pharo By Example online book, so I will add this to the chapter. The chapter will target people not familiar with Object Orientation and people new to coding. Its not an immediate target but it will happen till the end of the year.   


On Wed, Aug 27, 2014 at 3:44 PM, Mariano Martinez Peck <[hidden email]> wrote:



On Wed, Aug 27, 2014 at 8:22 AM, webwarrior <[hidden email]> wrote:
As class is just an object in Smalltalk, it would be reasonable to believe
that #initialize message is always sent to class on creation.

However, that's not true. It is only sent to classes that redefine
#initialize. Also sending super initialize may lead to problems.


Ohhh yes. There is always a time for every Smalltalkers where you discover that doing super for class side initialize is not a good idea.
 
None of these is mentioned in documentation (I assume Pahro By Example is
the official one). It only says that #initialize is sent when class is
loaded into memory.

I think either this behavior should be made more consistent, or excplicitly
mentioned in the docs.


+1 to the documentation 
 



--
View this message in context: http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




--
Mariano
http://marianopeck.wordpress.com

Nacho Smalltalker apprentice. Buenos Aires, Argentina.
Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

kilon.alios
you can read the book here


main repo is here


Sure exercises are always a good idea. We use pillar syntax which is quite simple, drop off to irc chat #Pharo at freenode to discuss the detail though most things are already well documented about the process of contributing to the book. 

I have ported so far 4 chapter and I am in chapter 5 , Damien has port one chapter and Stephan partly ported another so we around 50% of the book. 





On Thu, Aug 28, 2014 at 1:51 PM, Ignacio Sniechowski <[hidden email]> wrote:
Kilon,
Do you have a preview version of the updated book?
I would love to see it.
Also would you consider adding some exercises will be a good addition? I think so....let me know and i guess i can merge the project i've started to the updated book.
Best
Nacho

Enviado desde Molto para iPad

De: kilon alios
Enviado: miércoles, agosto 27, 2014 09:50 a.m.
Para: Any question about pharo is welcome
Asunto: Re: [Pharo-users] Unintuitive behavior of class-side initialize

I will be adding an "Introduction to Object Orientation" chapter to the new updated Pharo By Example online book, so I will add this to the chapter. The chapter will target people not familiar with Object Orientation and people new to coding. Its not an immediate target but it will happen till the end of the year.   


On Wed, Aug 27, 2014 at 3:44 PM, Mariano Martinez Peck <[hidden email]> wrote:



On Wed, Aug 27, 2014 at 8:22 AM, webwarrior <[hidden email]> wrote:
As class is just an object in Smalltalk, it would be reasonable to believe
that #initialize message is always sent to class on creation.

However, that's not true. It is only sent to classes that redefine
#initialize. Also sending super initialize may lead to problems.


Ohhh yes. There is always a time for every Smalltalkers where you discover that doing super for class side initialize is not a good idea.
 
None of these is mentioned in documentation (I assume Pahro By Example is
the official one). It only says that #initialize is sent when class is
loaded into memory.

I think either this behavior should be made more consistent, or excplicitly
mentioned in the docs.


+1 to the documentation 
 



--
View this message in context: http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




--
Mariano
http://marianopeck.wordpress.com


Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

nacho
thanks,
Im familiar with pillar as incontributed some stuff for the pharo for the enterprise.
I will take a look. Also
Thanks for your video tutorials, they are really awesome.
Please please continue to add more.
Take care
Nacho

Enviado desde Molto para iPad

you can read the book here


main repo is here


Sure exercises are always a good idea. We use pillar syntax which is quite simple, drop off to irc chat #Pharo at freenode to discuss the detail though most things are already well documented about the process of contributing to the book. 

I have ported so far 4 chapter and I am in chapter 5 , Damien has port one chapter and Stephan partly ported another so we around 50% of the book. 





On Thu, Aug 28, 2014 at 1:51 PM, Ignacio Sniechowski <[hidden email]> wrote:
Kilon,
Do you have a preview version of the updated book?
I would love to see it.
Also would you consider adding some exercises will be a good addition? I think so....let me know and i guess i can merge the project i've started to the updated book.
Best
Nacho

Enviado desde Molto para iPad

De: kilon alios
Enviado: miércoles, agosto 27, 2014 09:50 a.m.
Para: Any question about pharo is welcome
Asunto: Re: [Pharo-users] Unintuitive behavior of class-side initialize

I will be adding an "Introduction to Object Orientation" chapter to the new updated Pharo By Example online book, so I will add this to the chapter. The chapter will target people not familiar with Object Orientation and people new to coding. Its not an immediate target but it will happen till the end of the year.   


On Wed, Aug 27, 2014 at 3:44 PM, Mariano Martinez Peck <[hidden email]> wrote:



On Wed, Aug 27, 2014 at 8:22 AM, webwarrior <[hidden email]> wrote:
As class is just an object in Smalltalk, it would be reasonable to believe
that #initialize message is always sent to class on creation.

However, that's not true. It is only sent to classes that redefine
#initialize. Also sending super initialize may lead to problems.


Ohhh yes. There is always a time for every Smalltalkers where you discover that doing super for class side initialize is not a good idea.
 
None of these is mentioned in documentation (I assume Pahro By Example is
the official one). It only says that #initialize is sent when class is
loaded into memory.

I think either this behavior should be made more consistent, or excplicitly
mentioned in the docs.


+1 to the documentation 
 



--
View this message in context: http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




--
Mariano
http://marianopeck.wordpress.com


Nacho Smalltalker apprentice. Buenos Aires, Argentina.
Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

demarey
In reply to this post by philippeback

Le 27 août 2014 à 19:04, [hidden email] a écrit :

Yeah don't do super initialize unless you know why on the class side.

That being said class side initialize is pretty cool when loading new packages and setting everything up automagically.

In my opinion, it would be better to have a package initialization method for that purpose. 


smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Unintuitive behavior of class-side initialize

kilon.alios
In reply to this post by nacho
ah nice then you already a contributor and you dont need permission to add to updated pbe repo. 

thank you for the kind words, when I started making them I had some doubts about how good they will be so I am very glad that people find them useful and that motivates me to keep making them. The video tutorials will continue non stop and soon as I finish with the core of pharo I would like to dive into Morphic. 




On Thu, Aug 28, 2014 at 2:05 PM, Ignacio Sniechowski <[hidden email]> wrote:
thanks,
Im familiar with pillar as incontributed some stuff for the pharo for the enterprise.
I will take a look. Also
Thanks for your video tutorials, they are really awesome.
Please please continue to add more.
Take care
Nacho

Enviado desde Molto para iPad

De: kilon alios
Enviado: jueves, agosto 28, 2014 08:02 a.m.
Para: Any question about pharo is welcome
Asunto: Re: [Pharo-users] Unintuitive behavior of class-side initialize

you can read the book here


main repo is here


Sure exercises are always a good idea. We use pillar syntax which is quite simple, drop off to irc chat #Pharo at freenode to discuss the detail though most things are already well documented about the process of contributing to the book. 

I have ported so far 4 chapter and I am in chapter 5 , Damien has port one chapter and Stephan partly ported another so we around 50% of the book. 





On Thu, Aug 28, 2014 at 1:51 PM, Ignacio Sniechowski <[hidden email]> wrote:
Kilon,
Do you have a preview version of the updated book?
I would love to see it.
Also would you consider adding some exercises will be a good addition? I think so....let me know and i guess i can merge the project i've started to the updated book.
Best
Nacho

Enviado desde Molto para iPad

De: kilon alios
Enviado: miércoles, agosto 27, 2014 09:50 a.m.
Para: Any question about pharo is welcome
Asunto: Re: [Pharo-users] Unintuitive behavior of class-side initialize

I will be adding an "Introduction to Object Orientation" chapter to the new updated Pharo By Example online book, so I will add this to the chapter. The chapter will target people not familiar with Object Orientation and people new to coding. Its not an immediate target but it will happen till the end of the year.   


On Wed, Aug 27, 2014 at 3:44 PM, Mariano Martinez Peck <[hidden email]> wrote:



On Wed, Aug 27, 2014 at 8:22 AM, webwarrior <[hidden email]> wrote:
As class is just an object in Smalltalk, it would be reasonable to believe
that #initialize message is always sent to class on creation.

However, that's not true. It is only sent to classes that redefine
#initialize. Also sending super initialize may lead to problems.


Ohhh yes. There is always a time for every Smalltalkers where you discover that doing super for class side initialize is not a good idea.
 
None of these is mentioned in documentation (I assume Pahro By Example is
the official one). It only says that #initialize is sent when class is
loaded into memory.

I think either this behavior should be made more consistent, or excplicitly
mentioned in the docs.


+1 to the documentation 
 



--
View this message in context: http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




--
Mariano
http://marianopeck.wordpress.com