new Object()->function() ?
new Object()->function() ?
am 01.10.2007 15:37:18 von Mtr
this results in "unexpected T_OBJECT_OPERATOR" Parse error
How do I do this, without needing two lines such as
$o = new Object();
$o->function();
Also, what does "unexpected T_OBJECT_OPERATOR" mean?
Re: new Object()->function() ?
am 01.10.2007 15:41:35 von Willem Bogaerts
(new Object())->function()
Mtr wrote:
> this results in "unexpected T_OBJECT_OPERATOR" Parse error
>
> How do I do this, without needing two lines such as
>
> $o = new Object();
> $o->function();
>
> Also, what does "unexpected T_OBJECT_OPERATOR" mean?
It means that the -> is unexpected at that point.
Best regards,
--
Willem Bogaerts
Application smith
Kratz B.V.
http://www.kratz.nl/
Re: new Object()->function() ?
am 01.10.2007 15:47:31 von zeldorblat
On Oct 1, 9:37 am, Mtr wrote:
> this results in "unexpected T_OBJECT_OPERATOR" Parse error
>
> How do I do this, without needing two lines such as
>
> $o = new Object();
> $o->function();
>
> Also, what does "unexpected T_OBJECT_OPERATOR" mean?
You don't. That syntax (new Object()->function()) isn't supported.
That's why you get "unexpected T_OBJECT_OPERATOR."
Re: new Object()->function() ?
am 01.10.2007 15:49:01 von Mtr
On Mon, 01 Oct 2007 15:41:35 +0200, Willem Bogaerts
wrote:
>(new Object())->function()
>
>Mtr wrote:
>> this results in "unexpected T_OBJECT_OPERATOR" Parse error
>>
>> How do I do this, without needing two lines such as
>>
>> $o = new Object();
>> $o->function();
>>
>> Also, what does "unexpected T_OBJECT_OPERATOR" mean?
>
>It means that the -> is unexpected at that point.
Yes, thanks, but more precisely: the "->" is not an operator, nor is it
text. (I assume that "T" is short for text.) So it's unclear what this
error msg means.
Let me refine my example, so as not to use any reserved word like
"function"
$o = new MyObject()->myFunction() does not work:
If I know what the error means, it will be easier to remember.
Re: new Object()->function() ?
am 01.10.2007 15:57:22 von zeldorblat
On Oct 1, 9:49 am, Mtr wrote:
>
> Yes, thanks, but more precisely: the "->" is not an operator, nor is it
> text. (I assume that "T" is short for text.) So it's unclear what this
> error msg means.
>
The T is short for "token."
Re: new Object()->function() ?
am 01.10.2007 15:58:36 von Michael Fesser
..oO(Mtr)
>On Mon, 01 Oct 2007 15:41:35 +0200, Willem Bogaerts
> wrote:
>
>>> Also, what does "unexpected T_OBJECT_OPERATOR" mean?
>>
>>It means that the -> is unexpected at that point.
>
>Yes, thanks, but more precisely: the "->" is not an operator
It is an operator, like "::".
>nor is it
>text. (I assume that "T" is short for text.)
The "T" means token.
>So it's unclear what this
>error msg means.
The parser simply doesn't expect a "->" token at that point.
>Let me refine my example, so as not to use any reserved word like
>"function"
>
>$o = new MyObject()->myFunction() does not work:
>
>If I know what the error means, it will be easier to remember.
The message is pretty clear. PHP doesn't support this syntax.
Micha
Re: new Object()->function() ?
am 02.10.2007 16:28:26 von Mtr
On Mon, 01 Oct 2007 15:58:36 +0200, Michael Fesser wrote:
>.oO(Mtr)
>
>>On Mon, 01 Oct 2007 15:41:35 +0200, Willem Bogaerts
>> wrote:
>>
>>Yes, thanks, but more precisely: the "->" is not an operator
>
>It is an operator, like "::".
oh really? then perhaps you can tell us what "operation" is being performed
Re: new Object()->function() ?
am 02.10.2007 17:07:10 von Michael Fesser
..oO(Mtr)
>On Mon, 01 Oct 2007 15:58:36 +0200, Michael Fesser wrote:
>
>>>On Mon, 01 Oct 2007 15:41:35 +0200, Willem Bogaerts
>>> wrote:
>
>>>Yes, thanks, but more precisely: the "->" is not an operator
>>
>>It is an operator, like "::".
>
>oh really? then perhaps you can tell us what "operation" is being performed
The object is dereferenced. From the manual:
| An operator is something that you feed with one or more values (or
| expressions, in programming jargon) which yields another value (so
| that the construction itself becomes an expression).
Micha
Re: new Object()->function() ?
am 02.10.2007 17:20:14 von Mtr
On Tue, 02 Oct 2007 17:07:10 +0200, Michael Fesser wrote:
>The object is dereferenced. From the manual:
>
>| An operator is something that you feed with one or more values (or
>| expressions, in programming jargon) which yields another value (so
>| that the construction itself becomes an expression).
quoting the manual can only try to indicate what the authors of PHP say.
That is not any proof that it really is an operator. If they say that the
sun is blue, would you believe that, too?
The fact is that no operation is being performed, and so "->" is not an
operator in the conventioned use of the term.
In another language, Object.property would not indicate that the dot is an
operator of any kind. The author(s) of PHP shot themselves in the foot
early on when they decided to use the the dot for string concatenation
rather than the same plus sign that nearly everybody else uses. So now they
have to use the clunky '->' where they should be using a dot. It still just
denotes that a method or variable belongs to the object.
Re: new Object()->function() ?
am 02.10.2007 17:55:22 von Mtr
On Tue, 02 Oct 2007 17:07:10 +0200, Michael Fesser wrote:
>The object is dereferenced. From the manual:
>
>| An operator is something that you feed with one or more values (or
>| expressions, in programming jargon) which yields another value (so
>| that the construction itself becomes an expression).
for instance, from the manual on Classes and Objects:
"To create an instance of a class, a new object must be created and
assigned to a variable."
That is just not true. The fact that it is in the manual doesn't make it
more true.
Re: new Object()->function() ?
am 02.10.2007 19:09:44 von Steve
"Mtr" wrote in message
news:uaq4g39q171n0c37fmdkeljjepsacbg1l8@4ax.com...
> On Tue, 02 Oct 2007 17:07:10 +0200, Michael Fesser wrote:
>
>>The object is dereferenced. From the manual:
>>
>>| An operator is something that you feed with one or more values (or
>>| expressions, in programming jargon) which yields another value (so
>>| that the construction itself becomes an expression).
>
>
> for instance, from the manual on Classes and Objects:
>
> "To create an instance of a class, a new object must be created and
> assigned to a variable."
>
> That is just not true. The fact that it is in the manual doesn't make it
> more true.
ROFLMFAO!!!
summary: "just cuz it's in the manual don't make it true...so, from the
manual, here's why i'm right."
what kind of fucked up thinking is that!?!!
hint: just cuz you say 'that is just not true' doesn't make it true. i
suggest you reread the manual! (for comprehension this time).
Re: new Object()->function() ?
am 02.10.2007 19:16:58 von Steve
"Mtr" wrote in message
news:m1o4g3d7np93ia9ekilh9608skb9ddbkrt@4ax.com...
> On Tue, 02 Oct 2007 17:07:10 +0200, Michael Fesser wrote:
>
>>The object is dereferenced. From the manual:
>>
>>| An operator is something that you feed with one or more values (or
>>| expressions, in programming jargon) which yields another value (so
>>| that the construction itself becomes an expression).
>
> quoting the manual can only try to indicate what the authors of PHP say.
> That is not any proof that it really is an operator. If they say that the
> sun is blue, would you believe that, too?
if they built the sun and said it was blue, yes, i'd tend to believe
them...rather than saying 'i know more than they, the sun is green'.
> The fact is that no operation is being performed, and so "->" is not an
> operator in the conventioned use of the term.
get a clue!
> In another language, Object.property would not indicate that the dot is an
> operator of any kind. The author(s) of PHP shot themselves in the foot
> early on when they decided to use the the dot for string concatenation
> rather than the same plus sign that nearly everybody else uses.
oh, so now you have several bitches you'd like to whine about!
> So now they
> have to use the clunky '->' where they should be using a dot.
"should'?!!! dumbass, that's straight out of c++. get your fucking head
outta VB.
> It still just
> denotes that a method or variable belongs to the object.
hint, quit whining and read the FM.
Re: new Object()->function() ?
am 02.10.2007 21:55:17 von Jerry Stuckle
Mtr wrote:
> On Tue, 02 Oct 2007 17:07:10 +0200, Michael Fesser wrote:
>
>> The object is dereferenced. From the manual:
>>
>> | An operator is something that you feed with one or more values (or
>> | expressions, in programming jargon) which yields another value (so
>> | that the construction itself becomes an expression).
>
> quoting the manual can only try to indicate what the authors of PHP say.
> That is not any proof that it really is an operator. If they say that the
> sun is blue, would you believe that, too?
>
> The fact is that no operation is being performed, and so "->" is not an
> operator in the conventioned use of the term.
>
But there IS an operation being performed. You are dereferencing the
object. And it has precedence (pretty high) and associativity (left to
right).
> In another language, Object.property would not indicate that the dot is an
> operator of any kind. The author(s) of PHP shot themselves in the foot
> early on when they decided to use the the dot for string concatenation
> rather than the same plus sign that nearly everybody else uses. So now they
> have to use the clunky '->' where they should be using a dot. It still just
> denotes that a method or variable belongs to the object.
And in another language (specifically C++ or Java), the dot is an
operator.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: new Object()->function() ?
am 02.10.2007 23:26:09 von Steve
"Jerry Stuckle" wrote in message
news:wLadnerBs7AzP5_anZ2dnUVZ_tjinZ2d@comcast.com...
> Mtr wrote:
>> On Tue, 02 Oct 2007 17:07:10 +0200, Michael Fesser
>> wrote:
>>
>>> The object is dereferenced. From the manual:
>>>
>>> | An operator is something that you feed with one or more values (or
>>> | expressions, in programming jargon) which yields another value (so
>>> | that the construction itself becomes an expression).
>>
>> quoting the manual can only try to indicate what the authors of PHP say.
>> That is not any proof that it really is an operator. If they say that the
>> sun is blue, would you believe that, too?
>>
>> The fact is that no operation is being performed, and so "->" is not an
>> operator in the conventioned use of the term.
>>
>
> But there IS an operation being performed. You are dereferencing the
> object. And it has precedence (pretty high) and associativity (left to
> right).
>
>> In another language, Object.property would not indicate that the dot is
>> an
>> operator of any kind. The author(s) of PHP shot themselves in the foot
>> early on when they decided to use the the dot for string concatenation
>> rather than the same plus sign that nearly everybody else uses. So now
>> they
>> have to use the clunky '->' where they should be using a dot. It still
>> just
>> denotes that a method or variable belongs to the object.
>
> And in another language (specifically C++ or Java), the dot is an
> operator.
lol. i was going to ask him what term he gave a 'dot'...seems like 'denotes
that a method or variable belongs to the object' is a bit looong AND obtuse.
;^)