What's better about Ruby than Python?
newsgroups at jhrothjr.com
Mon Aug 18 19:40:36 CEST 2003
"Terry Reedy" <tjreedy at udel.edu> wrote in message
news:b8GdnQTH7KaPa92iXTWJkg at comcast.com...
> "John Roth" <newsgroups at jhrothjr.com> wrote in message
> news:vk1c89jvdjepa4 at news.supernews.com...
> > 4. Shortcut syntax for writing self in a method body.
> If you declare the first param as 's', for instance, then your
> shortcut is 's.', which is pretty minimal, and hardly enough, it seems
> to me, to make much fuss over. I like having a clean visual
> separation between local variables and instance attributes.
This particular issue has been debated a number of times, and one
of the answers that always comes up is the one you trot out.
Just about everyone uses "self" for good reason: everyone else
uses "self", so it communicates its meaning clearly. If everyone
suddenly decided to use their own terms, program readability
would go down across the board; unless, of course, the only
programs you read are your own.
This is why Ruby's solution is superior: "self" is a reserved word,
and so is the special character shortcut. There is no question as
to what is meant. It eliminates essentially futile arguements in the
same way that Python's indentation eliminates arguements about
the proper placement of braces.
More information about the Python-list