2009/6/29 Cameron Sanders csanders.personal@functional-analyst.com:
I didn't read your example closely, but, generally....
(obj respondsTo: #isCVLambda) and: [ obj isCVLambda ]
can't do that for lambdas, because it traps all DNU's and in this case a send of #respondsTo: (or any other unknown message) will be converted into a lambda message send instead of answering expected result. Because:
lambda := LambdaSlot id: #x. lambda foo ==> lambda( <x> #foo)
is very general (independent of hierarchy), or if you want to trap people on a class tree...
obj isKindOf: CVLambda
sorry, but this even worse than using #isXXX
or trap exceptions for when something doesn't respond to isCVLambda ...
or...
-- BUT, it will be slower.
an intriguing idea is having Object always respond to any pattern isXXX with false, unless the method is explicitly defined. (Now there I go, changing the root behavior...)
Exactly :)
Maybe it worth add and standardize the #is: message for Object ? Which by default can be implemented as:
Object is: object ^ self == object
and if you need to add the differentiation, then could be something like:
Object is: object ^ object == #lambda or: [ super is: object ]
-Cam
On Jun 29, 2009, at 1:18 PM, Igor Stasenko wrote:
so, here the question, can i implement the same behavior w/o using #isCVLambda , and