Thanks for the clarification everyone!
I wouldn’t have expected it to have different meaning depending on he
object/class type. I’ll keep an eye out for that.
Frederick Cheung wrote:
are methods in Ruby. Not all methods are operators, but that’s another
syntactic issue.
If we’re being pedantic, then not all operators are methods: ! is not
a method, nor is ?: and != is hardwired to be the negation of ==
(there are a few others eg &&, :: et.)
Ack, you’re right. I keep forgetting that unlike Smalltalk or C++, not
every operator is a method call. Sorry about the error. (However, <<
is both.)
Best,
–
Marnen Laibow-Koserhttp://www.marnen.org
mar...@marnen.org
Yes, everything in Smalltalk is a method or commonly referred to as a message that’s always
sent to an object. However, in C++, everything can be thought of as a method but a method in
C++ can have further semantic meanings because it was derived from C. For example,
if I say write a method, one tends to think within a class using a message passing style
if I say write a function, one tends to think of a C style representation using a non-message
passing style sometimes
Next, one cannot overload the C and C++ operators within C++: ‘.’, ‘?:’, ‘sizeof’, ‘::’, and
‘.*’. Although, they are technically considered operators within the language.
In short, I tend to think of operators as a specialized class of methods which have been derived
from non-alphabetic characters and they have their particular usage constraints. Also, the use of
the word, method, means semantically different things in different languages.
-Conrad