开发者

Is there a name for this: "->"

开发者 https://www.devze.com 2023-03-12 22:02 出处:网络
This has popped up today and 开发者_运维问答we don\'t know a single name for it. Ie. $this->SessionThe Arrow OperatorI will take a C or C++ perspective when answering this question, although the la

This has popped up today and 开发者_运维问答we don't know a single name for it. Ie. $this->Session


The Arrow Operator


I will take a C or C++ perspective when answering this question, although the lack of -> in languages like Java, seems to fit the definitions below well.

According to the ANSI C Standard, Section 6.5.2.3: the "->" operator is defined as:

  • "Structure/union pointer operator,"
  • "Member access operator," (. and ->),
  • "Pointer operator,

Compare the . operator, which is defined in Section 6.3.2.11 as the "Structure/union member operator." The member access operator -> is defined as one of a number of punctuators in Section 6.4.61:

"A punctuator is a symbol that has independent syntactic and semantic significance. Depending on context, it may specify an operation to be performed (which in turn may yield a value or a function designator, produce a side effect, or some combination thereof) in which case it is known as an operator (other forms of operator also exist in some contexts). An operand is an entity on which an operator acts."1

See:
ISO/IEC 9899:TC3, Committee Draft — Septermber 7, 2007, WG14/N1256 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf


I would call it "arrow", but that's certainly subjective :)


C++ manual names it as "Member b of object pointed to by a", so can it be pointing operator?

In PHP, it is called object operator.


How about this one: "Object Operator"


This came up w.r.t. C++ as part of another question.

Really, the answer will completely depend on the language used, though some people use the term "arrow operator" as a visual cue, which can be language-agnostic.


$this refers to the current module you are in and arrow sign is used for memory reference. Check this for concept. For php examples refer here

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号