Methods *are* first class objects:
Yes, in one sense they are. That's true. But not in the sense that they
readily accessable and *carry state* (as in Python, FWIBT). That's the
important missing element.
Not necessarily, see the first code example above (UnboundMethod). Note
also that you can convert between the two types:
=> #<Method: Foo#bar>
Hmm... I see more clearly now how rebinding unbound methods "reinstates" the
method. But still, unbound methods seem useless. They can only be rebound to
the same kind of class. Until that changes what real use are they? But
perhaps in the future...(matz?) Then again I think someone did once show me
an example of how unbound methods could be useful, but it was rather tricky
and hence not very useful
Hmmm... but I do see that I might be able to finish my original proposal using
them. That might work. So the constant method would be the class-level
version. Oh, that might blend nicely with the capitalized methods for the
instance level version --they will look identical except for the parens.
Ameth - unbound
Ameth() - bound
Not bad. Perhaps with a little extra umph I can use that absent argument too.
Maybe for bounding to a different object? [just thinking out loud here]
class Object
alias
ld_method :method
def method(s)
( @methods ||= {} )
||= old_method(s)
end
end
nice. a bit more concise then my version. that will work, despite the extra
verbosity, methodameth) -or- @methods[:ameth].
thanks,
T.