Re: Re: Declare minimum PHP version required?

From: Date: Wed, 05 Feb 2014 06:45:34 +0000
Subject: Re: Re: Declare minimum PHP version required?
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
This feature may be too expensive, because it would slowdown every function
call even with hooks disabled (to check if they are enabled).
It's also going to complicate execution because separate peaces of code are
going to use the same variables. So VM will have to construct and use
symbol table (hash table) instead of CV (directly indexed variable slots).

Thanks. Dmitry.


On Wed, Feb 5, 2014 at 2:37 AM, Yasuo Ohgaki <[email protected]> wrote:

> Hi all,
>
> On Mon, Feb 3, 2014 at 3:58 PM, Yasuo Ohgaki <[email protected]> wrote:
>
> > I thought it might be good for us to have declaring minimum PHP version
> > required to execute script.
> > http://jp1.php.net/manual/en/control-structures.declare.php
> >
>
> I have concluded that these check should be done by new assert()
>
> https://wiki.php.net/rfc/expectations
>
> I think of another idea for declare(). Current declare() has 'tick'.
> How about have hooks 'pre_hook' and 'post_hook'?
>
> It works like tick. Tick executes registered function/code by execution
> cycle.
> 'pre_hook' and 'post_hook' executes registered function/code before
> function call
> and after function call. Something like
>
> declare(pre_hook=TYPE) { some_useful_code }
> declare(post_hook=TYPE) { some_useful_code }
>
> Where TYPE is 0=none, 1=user, 2=internal, 3=both.
> 'none' is for to use hook inside function body.
>
> These hooks are executed like
>
> function foo() {
>    // pre_hook hook here
>    some useful code
>    // post_hook hook here (executed for all 'return')
> }
>
> This is useful for user land PHP debugger/profiler as well as pre/post
> condition checks. We have dbg, but it's nice to have hook in user
>  land for simple debugging and profiling also. It may be convenient if
> hooked functions/methods can be specified, but it might be headache
> with namespace. Simply hooking all calls might be simpler as it does
> not have to be fast.
>
> Or declare() may be used inside functions.
>
> function foo() {
>    declare(pre_hook=0) { some useful code }
>    declare(post_hook=0) { some useful code }
>    body
> }
>
> There are many way for hook design.
> Just an another idea for declare().
> It would be useful, but it lacks elegance...
> Since declare() is compiler directive, INI is needed for enabling/disabling
> when user want hook for all files.
>
> Any comments for this feature?
>
> Regards,
>
> --
> Yasuo Ohgaki
> [email protected]
>


Thread (50 messages)

« previous php.internals (#72241) next »