Re: reference caller object
| From: | Chris Trahey | Date: | Sat, 19 Sep 2009 14:54:57 +0000 |
| Subject: | Re: reference caller object | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-45615@lists.php.net to get a copy of this message | ||
I guess what I'm really getting at is another access modifier:
private, protected, public...
And now adding something like trusted.
trusted function myMethod() callable trustedInterface {}
In a case like this, caller would always be available, but not always type-checked.
Chris Trahey
Web Applications Developer
Database Administrator
College Station I.S.D.
On Sep 19, 2009, at 9:45 AM, Chris Trahey <ctrahey@csisd.org> wrote:
Okay, that gets me thinking. First of all, we still would need to decide if the language should withhold a feature to "help" the users. It's really up to them how they use this basic reference. You've brought up a good point, but surely there are certain situations... Unless... We can discuss a more drastic change in the language to accomodate cleaner code that still has access to the caller: Type hinting method signatures with additional keywords, such as: public function myMethod($arg) callable trustedClass trustedInterface { // caller is instance of trustedClass or impliments trustedInterface or we have Exception } Surely there would be a few ways to skin this cat, but it solves the "friend class" relationship without if(instanceof)... which would be pretty cool. Chris Trahey Web Applications Developer Database Administrator College Station I.S.D. On Sep 19, 2009, at 9:04 AM, "Jared Williams" <jared.williams1@ntlworld.com wrote:-----Original Message----- From: Stan Vassilev [mailto:sv_forums@fmethod.com] Sent: 19 September 2009 11:33 To: troels knak-nielsen; Ford, Mike Cc: internals@lists.php.net Subject: Re: [PHP-DEV] reference caller objectIt is considered a code smell, using instanceof in conditionals. "ttp://c2.com/cgi/wiki?InstanceofInConditionals And should be refactored with... "ttp://c2.com/cgi/wiki?ReplaceConditionalWithPolymorphism JaredI, for one, am quite happy that it's fairly complicated andconvolutedto get the caller of a method, since it could lead to someseriouslyincomprehensible code in the hands of someone who don't knowwhat theyare doing. Requiring the user to use the backtrace is aclear warningsign, and I think that's a good thing.What is the basis for all this. When someone says a feature is "ugly" and it leading to "seriously incomprehensible code", I'd really like this is explained and supported by evidence somehow, than just thrown around without facts. Most OOP languages expose the caller in some fashion. You'll be hard at work to see in which of them it led to masses of convoluted code.