I know that
MyObject.myMethod();
is refered to as dot notation.
But what is
MyObject->myMethod();
called?
Also are their others?
|
I know that
is refered to as dot notation. But what is
called? Also are their others? |
||||
| show 6 more comments |
|
It's typically referred to as "pointer notation", at least in C/C++ circles. [Adding] Used when the variable is a pointer and points to an address. That address is typically another variable, but can be a pointer to a function. |
||||
|
|
|
If you're using PHP that's the same.
Otherwise, pointer notation as mentioned. |
||||
|
|
|
It is often called pointer notation or arrow notation. Personally I prefer arrow because that is what it looks so others will know what you are talking about even if they have not heard the term before. |
|||||
|
Yes of course. There's this notation in Objective-C:
I like to call it the WTF-notation, but I suppose that's incorrect :D
This actually looks pleasant at first, but nested calls of methods with multiple arguments will just really give you the aforementioned feeling. In accordance with those language's semantics you could maybe call them "message (passing) notation" or "(method) selector notation". |
|||||
|
|
If you're using C++ then it's used the same as a
However in PHP since
|
||||
|
|
|
Why do you need a name? I can't think of a time I've actually said "dot notation". If have to describe it, for instance when pair programming, I'd just say "you need a dot" or "use an arrow there". When reading C code, I tend to read (However, in languages where |
||||
|
|
|
In Haskell, F#, and other functional languages, the
The In Haskell the I'm not sure how you'd "pronounce" it though. I usually translate function definitions into something like what I said above. |
||||
|
|
|
Conceptually both denote "part of". MyMethod is a part (member) of MyObject. In languages like C and C++, where you can have objects and pointers to objects, the "." syntax is used with objects (and references) and "->" syntax is used with pointers. |
||||
|
|
|
Perl calls it method invocation. Used transparently, it's just like dot or method notation in other languages. But internally, it is syntactical sugar for function calls on classes, since Perl5 lacks real objects.
Edit: Thanks to Sean for pointing out that I incorrectly referred to it as "indirect object notation". Indirect is when it doesn't use the arrow at all! |
|||||
|
Yes, there's also bracket notation:
It's also sometimes referred to as "array notation" and similar, due to arrays using this style too, even though it's not an array here. |
||||
|
|
|
Since you gave no context at all, I'll just muddy the waters further by saying that in C++0x when you need to tell the compiler your lambda's return type, you do that with a -> also:
Since those two characters mean different things in different languages, or even in different places in the same language, it's not surprising there's no single answer to " -> is called ___ notation". I call the character "arrow" if I want someone to type it ("dash-greater-than" if I'm dealing with someone really inexperienced and confused), and I pronounce it "points to" when it's being used like your dot-notation example, and "returns" in the lambda example I just gave above. |
||||
|
|
|
In Clojure -> is the threading macro. It is used to pass a value through a set of expressions, with each expresion determining the value to be passed to the next expression. The value is that this enables you to compose sequences of of operations such as:
|
||||
|
|
|
At least in C/C++, it could conceivably still be called a "dot" operator:
But yes, "arrow" (based on shape), "at" (another answer), and "to" (what I think of) are more common. |
||||
|
|
|
In C++,
is the same as:
|
||||
|
|
|
From a C standpoint, there's no official designation. I've seen "dot" and "arrow" (obvious), "member selection" (for both), "component selection" (for both), "whoziewhatsit" (you get the picture), und so weiter. I prefer "member-" or "component access" over "dot" and "arrow" simply because it conveys what the operator does, but that's just me. |
||||
|
|
|
I've always called it the finger pointer. |
||||
|
|
int*). For member dereference, the dereferenced type must be an object (class or struct). In fact, in C++ you can overload the->operator of an object type. – rwong Nov 18 '10 at 5:52