Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-02-01 Thread S.A.N
2015-02-01 21:41 GMT+02:00 Rowan Collins : > On 31/01/2015 23:42, S.A.N wrote: >> >> Yes, you're right, in PHP you can solve this problem by other methods, i >> know... >> >> But the problem is that PHP is no nice and convenient for solving this >> problem. >> So i suggested to add new keyword, not

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-02-01 Thread Rowan Collins
On 31/01/2015 23:42, S.A.N wrote: Yes, you're right, in PHP you can solve this problem by other methods, I know... But the problem is that PHP is no nice and convenient for solving this problem. So I suggested to add new keyword, not to do manually bindTo($this) for each methods. Have a closer

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-02-01 Thread Tony Marston
""S.A.N"" wrote in message news:CALW=WEDFmUXap7Bx=chhx5vyhcoi1kbahgdkjif2adlx6yt...@mail.gmail.com... 2015-02-01 1:52 GMT+02:00 Stanislav Malyshev : Hi! The reason for creating circular references, usually due to the need to bind objects. But this relationship can often be obtained from the

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-02-01 Thread Patrick Schaaf
Am 01.02.2015 01:15 schrieb "S.A.N" : > > $holder->object->call($holder); The way I solve this in the very few places (*) where it makes sense, is to use __call in the holder class to implement forwarding methods that pass on the holder object reference. The member property is NOT exposed. Call w

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-31 Thread Stanislav Malyshev
Hi! > Everything is relative, when there is an experience in a dynamic > context (this) in JS, while unwieldy structure in PHP code look > something old and not comfortable. In this case I'd suggest you to write your PHP code in wieldy structure so it would be comfortable ;) I'm not sure what exa

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-31 Thread S.A.N
2015-02-01 2:23 GMT+02:00 Stanislav Malyshev : > Hi! > >> If the caller explicitly send the object as an argument, it worsens >> loose depending API. >> >> And agreed this code looks weird and not well thought-out: >> > >> $holder->object->call($holder); > > This code explicitly says "object->call

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-31 Thread Stanislav Malyshev
Hi! > If the caller explicitly send the object as an argument, it worsens > loose depending API. > > And agreed this code looks weird and not well thought-out: > > $holder->object->call($holder); This code explicitly says "object->call() is using $holder". It is clear and unambiguous. If you

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-31 Thread S.A.N
2015-02-01 1:52 GMT+02:00 Stanislav Malyshev : > Hi! > >> The reason for creating circular references, usually due to the need to >> bind objects. >> >> But this relationship can often be obtained from the context of the call. > > If the API behaves differently depending on who is calling it, or >

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-31 Thread Stanislav Malyshev
Hi! > The reason for creating circular references, usually due to the need to > bind objects. > > But this relationship can often be obtained from the context of the call. If the API behaves differently depending on who is calling it, or requires some information from the caller, it should be pa

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-31 Thread S.A.N
2015-02-01 0:10 GMT+02:00 Rowan Collins : > On 31/01/2015 19:41, S.A.N wrote: >> >> No, I'm not describing this behavior, but I chose the wrong name >> keyword, this is not perceived correctly. >> >> My source code examples, it is clear that no returns previous object >> from the call stack, me nee

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-31 Thread Rowan Collins
On 31/01/2015 19:41, S.A.N wrote: No, I'm not describing this behavior, but I chose the wrong name keyword, this is not perceived correctly. My source code examples, it is clear that no returns previous object from the call stack, me need return references to the holder object. It's more like t

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-31 Thread S.A.N
No, I'm not describing this behavior, but I chose the wrong name keyword, this is not perceived correctly. My source code examples, it is clear that no returns previous object from the call stack, me need return references to the holder object. It's more like the dynamic of "this" in JavaScript.

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-30 Thread Ferenc Kovacs
On Fri, Jan 30, 2015 at 3:53 AM, S.A.N wrote: > The reason for creating circular references, usually due to the need to > bind objects. > > But this relationship can often be obtained from the context of the call. > > It will be very convenient to have a keyword that will return reference to > an

RE: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-29 Thread François Laupretre
> De : Larry Garfield [mailto:la...@garfieldtech.com] > > Having an object that behaves differently depending on an implicit > relationship with where it happened to be called from is full of all > kinds of impossible to debug magic. I don't even know how you'd unit > test it. I can think of no u

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-29 Thread Larry Garfield
On 01/29/2015 10:30 PM, S.A.N wrote: I will clarify the benefits of the keyword. Single instance of the class can reused in different contexts calls. object = $c; $b->object = $c; $a->object->getCaller(); // return A $b->object->getCaller(); // return B $c->getCaller(); // Fatal Error - undefi

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-29 Thread S.A.N
I will clarify the benefits of the keyword. Single instance of the class can reused in different contexts calls. object = $c; $b->object = $c; $a->object->getCaller(); // return A $b->object->getCaller(); // return B $c->getCaller(); // Fatal Error - undefined caller context ?> 2015-01-30 5:50

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-29 Thread S.A.N
Yes. But this creates a static link that will not be constantly changing context to the calls, the keyword will give a dynamic abstract communication. 2015-01-30 5:50 GMT+02:00 Juan Basso : > Usually it is solved sending the $this instance to class C constructor and > C object storing it in some

Re: [PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-29 Thread Juan Basso
Usually it is solved sending the $this instance to class C constructor and C object storing it in some attribute, solving the problem. I don't think a new keyword would help. Juan Basso On Thu, Jan 29, 2015 at 9:53 PM, S.A.N wrote: > The reason for creating circular references, usually due to t

[PHP-DEV] Use "caller" keyword, to access object caller.

2015-01-29 Thread S.A.N
The reason for creating circular references, usually due to the need to bind objects. But this relationship can often be obtained from the context of the call. It will be very convenient to have a keyword that will return reference to an object, which caused this object. Sorry for my English, I'