Skip to end of metadata
Go to start of metadata

Python does not seem to treat calling objects completely uniformly.

A class which defines a _call_ method, such as

may then be called using the same syntax as a function.

If you define a function, then the resulting object does have a _call_ method, but changing that method (say to an integer) does not affect your ability to call the function.

Another interesting twist is demonstrated in the following example:

Objects b and c demonstrate that the actual function may be arbitrarily many _calls away. Object a shows that python only checks the Class type when it is looking for the __call_ attribute.


My stack frames are

 0: dynamic link (the old fp)
-4: static link (fp to enclosing scope)
-8: first param
-4*(nParam+nLocal+1): space for the last local (this is where $sp points)

I wanted to have positive offsets, but this way it is easy to restore once the function returns.

  • No labels