Python dynamic attribute creation

WANG Cong xiyou.wangcong at gmail.com
Thu Jul 1 11:15:23 EDT 2010


On 06/28/10 17:43, Bruno Desthuilliers <bruno.42.desthuilliers at websiteburo.invalid> wrote:

> Carl Banks a écrit :
>> On Jun 27, 3:49 am, Bruno Desthuilliers
>> <bdesth.quelquech... at free.quelquepart.fr> wrote:
>>> WANG Cong a écrit :
>>>
>>>> On 06/26/10 00:11, Neil Hodgson <nyamatongwe+thun... at gmail.com> wrote:
>>>>> WANG Cong:
>>>>>> 4) Also, this will _somewhat_ violate the OOP princples, in OOP,
>>>>>> this is and should be implemented by inherence.
>>>>>    Most object oriented programming languages starting with Smalltalk
>>>>> have allowed adding attributes (addInstVarName) to classes at runtime.
>>>> Thanks, I have to admit that I know nothing about Smalltalk.
>>> Then you really don't know much about OO.
>>
>> I don't really know much about Smalltalk either.
>>
>
> Duh. I cancelled this totally stupid and useless post a couple seconds
> after hitting the send button, but still too late :(
>
> So first let me present my apologies to WANG Cong and everyone else,
> this was a crude, arrogant and totally stupid thing to say, and I
> should know better. Sorry.
>

No problem. :)

> Now on why I first wrote this (warning : personal opinions ahead):
>
> "object" started with Simula, but objects in Simula are mostly
> glorified ADTs with type-based "polymorphic" dispatch. Smalltalk (and
> all it's environment) got _way_ further  by turning this into a
> coherent whole by introducing messages (which are more than just
> type-based polymorphic dispatch - Smalltalk's messages are objects
> themselves) and "code blocks" - as the only mean to control "flow". I
> believe that Smalltalk is (so far) the only "OO" language that was
> innovative enough to really escape from good old procedural
> programming, and as such possibly the only "True" OOPL.
>
> Now for various reasons (including implementation issues and
> conservatism), it happened that the Simula approach to OO became the
> mainstream with languages like C++ then Java, and that most of "OO"
> litterature - "OOP principles", golden rules etc - is about this
> somehow very restricted approach, so people being taught "OO" that way
> have a very restricted - and incomplete - vision of what OO is really
> about. That was how I was taught OO, and I always felt that there was
> something wrong, inconsistant or missing.
>
> Studying Smalltalk (however briefly) was for me a real "AHA",
> mind-opening moment - suddenly OO made sense as this coherent,
> comprehensive and innovative approach to programming I so far failed
> to find in Java or C++.
>
> Now I don't mean one has to master Smalltalk to be allowed to talk
> about OO, nor that OO can't exist outside Smalltak (Python being IMHO
> another exemple of an interesting and mostly coherent object system,
> even if doesn't go as far as Smalltalk do), but - pardon me if this
> seems arrogant (and please correct me if it really is) - I can't help
> thinking that one cannot really understand OO whithout at least a
> brief study of Smalltalk (and - once again - a full Smalltalk
> environment, as Smalltalk the language is only one part of the 'full'
> object system).
>

This sounds really cool, I think I should find some time to learn
Smalltalk, even only considering historic reasons.

Thanks for sharing your Smalltalk learning experience with us!


-- 
Live like a child, think like the god.
 



More information about the Python-list mailing list