Re: caller function?
| From: | Tom Fishwick | Date: | Thu, 14 Dec 2000 14:12:18 +0000 |
| Subject: | Re: caller function? | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-41368@lists.php.net to get a copy of this message | ||
Zeev Suraski wrote:
>
> At 04:01 14/12/2000, Tom Fishwick wrote:
> >Hi!
> >
> >Anyone here working on a caller() function? I spent a couple hours last
> >night looking through the zend code, and I think may be able to do it,
> >but if someone more experianced is working on it then I'll leave it
> >alone. If no one is working on it, could someone give me a hint or two
> >on where to start, or how it would be implemented _correctly_?
>
> What's the caller() function supposed to do? If it's displaying the
> calling function name, there's no way of doing this now without slowing
> down execution time for all function calls.
something like list($function, $filename, $line) = caller(); is what I
meant (so you assumed right). For me, personally, I'm not worried if
the script is a little slower, if it saves me some debugging time or
allow me to pinpoint an error from a log entry then it's well worth it.
I took a couple hours put in a caller function to zend, it works, but
I'll admit I haven't tested it too much yet, one thing it doesn't do is
prepend the class name to a method...
>
> >Also, any thoughts on some type checking syntax? ie.
>
> We're not getting into this now. It's a major concept change and should be
> discussed (I'm generally against it, definitely when talking about
> primitive types - perhaps with the future OO support).
I agree with the primitive types, I was thinking more about the objects
though. I think the type casting syntax works well for this. The past
week I've been debugging a system written in php and _many_ of the bugs
have been becaause the wrong object type has been been passed to a
method. I either need to add code to check the object type for each
method or have some other kind of type checking, I think that this:
function blah((Person)$person) { }
looks much better than:
function blah($person) {
if(get_class($person) != 'Person')
trigger_error(E_USER_ERROR, '$person must be a Person object');
}
the more I can separate logic code and the error checking code the
better, which is my main reason for wanting a caller() and type checking
operator.
>
> Zeev
>
> --
> Zeev Suraski <zeev@zend.com>
> CTO, Zend Technologies Ltd. http://www.zend.com/
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
> For additional commands, e-mail: php-dev-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net