Rob S. wrote:
How is this better then having send and the __send alias, along with
the corresponding bang methods? It seems to me having one method that
means “send a message”, and then having one version be the “dangerous”
version is much more obvious then having object_send and
instance_send.
I just explained that. I’m sorry but I don’t understand how is is not
clear. I guess all I can do is try to sum up on a bullet point basis:
-
you have 4 methods when only 2 are needed
-
and two of those methods are ugly shadow methods
-
#send is common enough a word as to be too easily over-ridden
-
using #__send to circumvent this makes #send completely pointless
If a ruby newbie tried “send” and saw it fail due to a private method,
I bet once they saw “send!” in the docs or in irb they would
immediately know how it works. Its aligns perfectly with many other
things in the std lib, and fits perfectly with POLS.
not really since 90+% of the time “!” means in place change. personally
i could care less about the !, to me that’s not really the point –
there’s a more fundamental issue here. To me POLS is
-
methods starting with ‘object_’ or ‘instance_’ are Vital methods and
should not be overridden (unless you know exactly what the heck it is
you’re doing) -
methods starting with ‘instance_’ provide Internal access to the
receiver.
As for protecting from people overriding it, I think having the
underscore forms is enough. YSYEO (“You’ll shoot your eye out.”) I’m
sure there are programs were object_id and other meta-methods are
overridden. All you can do is warn people against doing it, test your
code, and of course choose libraries that behave well.
There was a reason #id was changed to #object_id.
T.