We don't have final design yet. just idea(s) and a question - should we try
to do it for PHP7 or later or not at all.

Thanks. Dmitry.



On Mon, Feb 16, 2015 at 3:43 PM, Cesar Rodas <ce...@rodas.me> wrote:

>
> On 16/02/15 13:40, Alexander Lisachenko wrote:
> > 2015-02-16 15:31 GMT+03:00 Benjamin Eberlei <kont...@beberlei.de>:
> >
> >> My question is how do i evaluate this at runtime? I suppose a function
> is
> >> necessary like evaluate_ast(...), but  that requires passing the
> context.
> >> many many open questions and as nikic points out this should probably be
> >> delayed to 7.1 because it all should be discussed and specified.
> >>
> > This will be like pretty simple to parse:
> > // For scalars:
> > $attributes = (new ReflectionMethod(some::class,
> 'method))->getAttributes();
> > $cacheableNode = $attributes[Cacheable::class] ?? new
> > Php\Parser\Node(AST_TYPE_VALUE, 50);
> > $cacheTime = $cacheableNode->value;
> >
> > // For more complex things, like expressions or constant, runtime
> > evaluation can be performed.
> > $codeNode = $attributes[Php\Contract\Requires::class] ?? new
> > Php\Parser\Node(AST_TYPE_STATEMENT, '$this->value >=0');
> > $code = (string) $codeNode;
> > $result = eval($code);
> >
>
> So, do we have the interpretation/evaluation of the ASP to the userland?
> That could good or bad.
>
> Good: It's pretty flexible
> Bad: Not so as fast as doing it in C. It's not easy to understand how to
> use it (but I'm sure most annotation libraries would do it for you, so
> no that bad).
>
> Am I missing something?
>
> --
> César D. Rodas
> Open Source developer
> +595-983-161124
> PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6
>
>
>

Reply via email to