Operators for everything (was Re: Operators for matrix)
Cliff Crawford
cjc26 at nospam.cornell.edu
Tue Jul 25 20:30:35 EDT 2000
* Paul Prescod <paul at prescod.net> menulis:
|
| I think name-based binary operators are actually pretty neat and can be
| used very Pythonically. IMO, they are the right compromise between
| terseness and legibility.
They sorta remind me of Smalltalk's keyword messages:
startTime addTime: delta (adds delta to startTime)
Date daysInMonth: #February forYear: 2000 (returns 28)
The parser can tell the keywords apart from the arguments because the
keywords all end in a colon. They're also more readable than regular
method calls; for example, the second example in Python would look
something like this:
Date.daysInMonth("February", 2000) or possibly
Date.daysInMonth("February", year=2000)
Guido's time machine must've gone really far back for this one;
Smalltalk dates from the 70's. :)
--
cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/
Synaesthesia now! icq 68165166
More information about the Python-list
mailing list