Jump to content


Photo

how do you say "->" ?


  • Please log in to reply
30 replies to this topic

#1 emehrkay

emehrkay
  • Staff Alumni
  • Advanced Member
  • 1,214 posts

Posted 19 June 2006 - 02:26 PM

you know as you type along you do x equals y
$x = $y;

what do you say when you do this?
$this->

i usually say this into...

does the -> have an actual name?

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 19 June 2006 - 04:44 PM

this may be a bit of an oversimplification, but after searching the PHP manual for a solution and coming up NULL, i figured i'd share my thoughts:

i generally simply refer to it as a "pointer."

i know i have to be careful, especially working with C++ programmers since it's a different animal than pointers in C, but that's my take on it. since it's not really an operator, i don't know that it has a name
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 emehrkay

emehrkay
  • Staff Alumni
  • Advanced Member
  • 1,214 posts

Posted 19 June 2006 - 04:58 PM

what do you say as you type it out?

$this->method();



#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 19 June 2006 - 05:31 PM

According to this page (2/3 down the page) its called the Object operator.

When I type the following:
$this->method();
I basically say call internal function method();

#5 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 19 June 2006 - 06:07 PM

According to this page (2/3 down the page) its called the Object operator.

very good eyes, wildteen

When I type the following:
$this->method();
I basically say call interal function method();

very similar here. i usually simply say something like "Object function method()." sometimes i'll go so far as to replace "Object" with the name of the Class it belongs to, if I'm working with multiple classes that have the same function names.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#6 emehrkay

emehrkay
  • Staff Alumni
  • Advanced Member
  • 1,214 posts

Posted 19 June 2006 - 08:25 PM

cool, thanks

#7 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 20 June 2006 - 03:45 PM

you know as you type along you do x equals y
$x = $y;

what do you say when you do this?
$this->

i usually say this into...

does the -> have an actual name?

actually,

$x = $y;

means assign the value of $y to $x.  it is not the same as saying $x equals $y. $x equal $y is what you'd say in a condition, like, if ($x == $y) { .. }  that is, if $x equals $y. 

= is assignment operator.
== is equality

as far as $this->blah .. if i have this:

$foo->bar = 'blah';

i usually say "assign 'blah' to bar of foo," or "assign 'blah' to foo's bar"

That's just how i 'say' it :\
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#8 emehrkay

emehrkay
  • Staff Alumni
  • Advanced Member
  • 1,214 posts

Posted 20 February 2007 - 09:42 PM

to

i am watching a slideshow of a class given by zend on oo php and the guy says "to"

$b->a

"b to a"

#9 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 20 February 2007 - 09:58 PM

i normal say "owns" (in my head of course).

not cos i'm some sort of 10 year old gaming txt spkr, but because that's how i kinda got to understand it.

$this->that (this owns that, or that belongs to this)
$b->a (b owns a, or a belongs to b)
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#10 Jessica

Jessica
  • Staff Alumni
  • This is not my name.
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 20 February 2007 - 11:28 PM

When I'm typing it, I generally call it "dot" because I started OOP with Java, and I just think to myself
class.method()
so I transfered that to php
$class->method() is still class dot method to me...
I guess I'm just weird. I've never had to say it out loud.
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#11 neylitalo

neylitalo
  • Staff Alumni
  • Advanced Member
  • 1,854 posts
  • LocationMichigan, USA

Posted 20 February 2007 - 11:30 PM

When I'm typing it, I generally call it "dot" because I started OOP with Java, and I just think to myself


That's exactly what I do - I say "dot" in my mind, but my fingers make the translation from "." to "->" all on their own.
http://nealylitalo.net - My personal website, and home of The Netizen's Journal.

#12 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 20 February 2007 - 11:53 PM

I say,

this->method();

this is method.

#13 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 21 February 2007 - 12:34 AM

I never really read my code aloud, but I have sometimes wondered how I would explain some code if I had to since I do not know the names.
--

i normal say "owns" (in my head of course).

not cos i'm some sort of 10 year old gaming txt spkr, but because that's how i kinda got to understand it.

$this->that (this owns that, or that belongs to this)
$b->a (b owns a, or a belongs to b)

0wn3d!!!1!!one1

#14 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 21 February 2007 - 12:47 AM

I don't call it anything or translate it into any sort of phrase.

Although if I did, I suppose I'd go with the following:

$foo->bar = 1;  ==> foo's bar equals 1

$foo->bar(); ==> foo does bar


PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#15 fert

fert
  • Members
  • PipPipPip
  • Advanced Member
  • 1,114 posts

Posted 21 February 2007 - 12:55 AM

I say pointer

Si hoc legere scis nimium eruditionis habes
Gentoo Linux 2007.0 Firefox 2

#16 dustinnoe

dustinnoe
  • Members
  • PipPipPip
  • Advanced Member
  • 187 posts
  • LocationWarner Robins, GA

Posted 21 February 2007 - 05:05 AM

you know your a geek when...

#17 ted_chou12

ted_chou12
  • Members
  • PipPipPip
  • Advanced Member
  • 1,488 posts
  • Location@ Mars

Posted 21 February 2007 - 08:47 AM

what does it look like??? to me, it looks obvious like an arrow. :P
Currently working on a website called NetFriending.co.cc, it is a free social networking site, features such as guestbook, blogs, are fully customizable in NetFriending, also has a forum to help you get to know others, if you are interested in the site, the url is: NetFriending.co.cc Hope everyone can get involved because the site is still quite new, so not much people are there at the moment, please feel free to leave a comment there or send a message to our staff. Register Here The link above is for registeration, it is 100% Free and Safe, everyone there is friendly and you can build your network. Photo sharing upload your own photos as well!!!

#18 Stopofeger

Stopofeger
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCTG, BD

Posted 22 February 2007 - 11:50 AM

I wonder why php used this syntax as they couldv'e easily used the "." operator as all other C type langs do. Java, C#, javascript and obviously c++.

Technically, "->" operator is used in c++ when accessing an object from a pointer. that is,
 obj* obj1= &someobj;
*obj->method;

I don't know the internals of php. But I think "->" is used just because "." is already "married??" with string concatation. Not because php uses pointers to access objs. 

Ok way offtopic. I call it dot. why bother using another word.
The world is round,
So the life is round.
It repeats and connects.

#19 Jessica

Jessica
  • Staff Alumni
  • This is not my name.
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 22 February 2007 - 04:08 PM

You answered your own question there... they can't just as easily use it because it's already being used...
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#20 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 24 February 2007 - 10:47 AM

I can't say why the PHP developers chose the -> operator over the dot operator, but I disagree with jesi's comment.

It's not terribly difficult to have one operator that performs different operations depending on the context in which it's used.  PHP already does it with LPAREN, which denotes function arguments or order of operations.  C++ uses context to allow function overloading.  Javascript uses the + operator for both string concatenation and arithmetic addition.
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users