[Tutor] best practice: throw exception or set a flag?

Bill Felton subscriptions at cagttraining.com
Fri Feb 4 18:02:59 CET 2011


Smalltalk is an OO programming language that had some dominance in the late 80's through much of the 90s.  It has proceeded to more or less commit suicide through a variety of mechanisms.
By 'drop' I meant 'drop the context of the remarks', which in the original post was discussing Smalltalk's default method return.
It isn't a major deal, overall, I think the most interesting remark has been Alan Gauld's musings immediately prior to Emile's to which I responded.
Python defaults to None.
Smalltalk defaults to self, which is always the object executing the code involved.
Alan points out that this is extremely convenient and can reduce the code bulk involved when one wishes to string multiple operations together.
It is stylistically possible in Python to set methods to return 'self' if/when that would be useful, but if it is not a language level feature, it becomes a convention that one can only rely on in ones own code.

regards,
Bill

On Feb 4, 2011, at 11:56 AM, Alex Hall wrote:

> On 2/4/11, Bill Felton <subscriptions at cagttraining.com> wrote:
>> Um, yes, emphatically yes.  You missed the context, which was Smalltalk, and
>> it is terms of Smalltalk that my reply is couched.
>> Yes, Python returns None.
>> Smalltalk returns self by default.
>> Given the dropped context, you are correct.
>> Given the context meant, I am.
> I was following this until now... what is this smalltalk and drop?
>> 
>> regards,
>> Bill
>> 
>> On Feb 4, 2011, at 9:28 AM, Emile van Sebille wrote:
>> 
>>> On 2/4/2011 5:35 AM Bill Felton said...
>>> 
>>>> Um, not quite correct -- methods *without a specified return value*
>>>> always return self, that is, the object which executed the method.
>>> 
>>> Um, no.  They return None.
>>> 
>>>>>> class Test:
>>> ...   def __init__(self):pass
>>> ...   def test(self):pass
>>> ...
>>>>>> a=Test().test()
>>>>>> a
>>>>>> print a
>>> None
>>>>>> 
>>> 
>>> Emile
>>> 
>>> _______________________________________________
>>> Tutor maillist  -  Tutor at python.org
>>> To unsubscribe or change subscription options:
>>> http://mail.python.org/mailman/listinfo/tutor
>> 
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>> 
> 
> 
> -- 
> Have a great day,
> Alex (msg sent from GMail website)
> mehgcap at gmail.com; http://www.facebook.com/mehgcap



More information about the Tutor mailing list