Inheriting the @ sign from Ruby
katz at Glue.umd.edu
Tue Dec 12 07:44:16 CET 2000
I was reading a Dr. Dobb's recently and it mentioned that Ruby uses the @
symbol to denote instance members of a class. This appeals to me because
I can comprehend it faster than seeing 'self' pasted in front of a
name, especially when the statement is buried in dense code.
Why not bind @ to the first argument of method definitions? Consider:
def __init__( self, x ):
@bind(x) # binds to 'self', because
# 'self' is the first argument to __init__
def bind(myself, x):
@x = x # equivalent to myself.x
What faults or strengths do you see with this?
More information about the Python-list