What's better about Ruby than Python?

Bengt Richter bokr at oz.net
Mon Aug 18 23:21:11 CEST 2003


On Mon, 18 Aug 2003 17:26:30 +0200, Alex Martelli <aleaxit at yahoo.com> wrote:
[...]
>
>One syntax difference that I do find important, and in Python's
>favour -- but other people will no doubt think just the reverse --
>is "how do you call a function which takes no parameters".  In
>Python (like in C), to call a function you always apply the
>"call operator" -- trailing parentheses just after the object
>you're calling (inside those trailing parentheses go the args
>you're passing in the call -- if you're passing no args, then
>the parentheses are empty).  This leaves the mere mention of
>any object, with no operator involved, as meaning just a
>reference to the object -- in any context, without special
>cases, exceptions, ad-hoc rules, and the like.  In Ruby (like
>in Pascal), to call a function WITH arguments you pass the
>args (normally in parentheses, though that is not invariably
>the case) -- BUT if the function takes no args then simply 
>mentioning the function implicitly calls it.  This may meet 
>the expectations of many people (at least, no doubt, those
>whose only previous experience of programming was with Pascal,
>or other languages with similar "implcit calling", such as
>Visual Basic) -- but to me, it means the mere mention of an
>object may EITHER mean a reference to the object, OR a call
>to the object, depending on the object's type -- and in those
>cases where I can't get a reference to the object by merely
>mentioning it I will need to use explicit "give me a reference
>to this, DON'T call it!" operators that aren't needed otherwise.
>I feel this impacts the "first-classness" of functions (or
>methods, or other callable objects) and the possibility of
>interchanging objects smoothly.  Therefore, to me, this specific
>syntax difference is a serious black mark against Ruby -- but
>I do understand why others would thing otherwise, even though
>I could hardly disagree more vehemently with them:-).
>
This is interesting, because I presume you are happy with properties ;-)

So is this basically a thing about the global namespace? I.e., if
we had way to introduce a subclassed module types into the import
mechanism, we could have module properties, which presumbaly could
be accessed much like parameterless Pascal functions.

Regards,
Bengt Richter




More information about the Python-list mailing list