Re: Use "caller" keyword, to access object caller.
2015-02-01 1:52 GMT+02:00 Stanislav Malyshev <[email protected]>:
> 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 passed
> explicitly - as a parameter/method call/etc. - not hidden. Otherwise it
> would lead to nasty surprises when the user of the API assumes caller
> does not matter but the implementor assumes it does.
> --
> Stas Malyshev
> [email protected]
This is a controversial statement.
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:
<?php
$holder->object->call($holder);
?>
Opportunity to shoot yourself in the foot, will always, developers
node.js it know.
I know that this code can be arranged differently, but then you have
to make it more difficult and not nice.
But if have an easy way to get a pointer to the owner, in practice, is
very convenient.
Thread (19 messages)