Added to the Users' Guide, section 4.3.3:
* Cheetah autocalls only functions and methods. Classes and other
callable objects are not autocalled. The reason is that the primary
purpose of a function/method is to call it, whereas the primary purpose
of an instance is to look up its attributes or call its methods, not to
call the instance itself. And calling a class may allocate large sums
of memory uselessly or have other side effects, depending on the class.
For instance, consider $myInstance.fname. Do we want to look up fname
in the namespace of myInstance or in the namespace of whatever
myinstance returns? It could go either way, and Cheetah can't tell. So
Cheetah follows the principle of least surprise and doesn't autocall
instances. If you do want to call the instance, do $myInstance.__call__.
If that's too inconvenient/ugly for you, rename the method to .__str__,
and it will be invoked any time $myInstance is used as a placeholder.
Note, however, that if $myInstance is in an expression rather than being
a placeholder, .__str__ will not be invoked.
-Mike (Iron) Orr, iron@... (if mail problems: mso@...)
http://iron.cx/ English * Esperanto * Russkiy * Deutsch * Espan~ol
Get latest updates about Open Source Projects, Conferences and News.