Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82841 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22616 invoked from network); 16 Feb 2015 13:00:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Feb 2015 13:00:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.181 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.181 mail-vc0-f181.google.com Received: from [209.85.220.181] ([209.85.220.181:34775] helo=mail-vc0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0A/65-29513-3E9E1E45 for ; Mon, 16 Feb 2015 08:00:19 -0500 Received: by mail-vc0-f181.google.com with SMTP id im6so10492939vcb.12 for ; Mon, 16 Feb 2015 05:00:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=tJ55HeY9x6/BNV28x9SLzhX9SslHjtJoYPPGY5C5oI4=; b=V3rfS0uI8iKcxQb7kzI1mq5E3w87hHoQEgZ7cVIlZb7VmGMqbDczw7IkbYScOG8eYk R0EINwtEV/PN+PkTIsR3r0Qcwoj6mE2SU+0h5nq824TAizOr02xdYRWlb1KQtj2ydXQg IynxKFOPR0WJGMF/CSWBf0SIHzLzzPnW9tG2eB3OCQdPMNIa636K7fZogSjTqiVvb/kC p4Atk+h6TdvHr+YJiP6JNxukU3ziULvTSwhbpu3LIMHeod9ShQCFtw/SZSGiIySMoEGV ojaENHlTX7NFT+AxSE6U2T659/H7CRgJwhG0QL+OkigHqzMdNcR3aMac9nJa/STIzF+F +8Hw== X-Gm-Message-State: ALoCoQlWEJ+Pu0Y5NtIoYPdiklFRrRWHrtzx/PTfgylCUZoPnEtxZ1XkkFJL8ynD3YZeqs3GfuF+gbgNABcuTBjCkWEsrNg+hUIzbxEBA29u3kCNaNGu/2EWwAFhttN89Oe3WfGI30CuCXXnxG/tbiwhinH0D6AIeA== MIME-Version: 1.0 X-Received: by 10.220.185.193 with SMTP id cp1mr15700508vcb.80.1424091616506; Mon, 16 Feb 2015 05:00:16 -0800 (PST) Received: by 10.52.74.73 with HTTP; Mon, 16 Feb 2015 05:00:16 -0800 (PST) In-Reply-To: <54E1E607.5020206@rodas.me> References: <54E1E607.5020206@rodas.me> Date: Mon, 16 Feb 2015 17:00:16 +0400 Message-ID: To: Cesar Rodas Cc: PHP Internals Content-Type: multipart/alternative; boundary=089e01538610ee1064050f342acc Subject: Re: [PHP-DEV] Annotations in PHP7 From: dmitry@zend.com (Dmitry Stogov) --089e01538610ee1064050f342acc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 wrote: > > On 16/02/15 13:40, Alexander Lisachenko wrote: > > 2015-02-16 15:31 GMT+03:00 Benjamin Eberlei : > > > >> 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 =3D (new ReflectionMethod(some::class, > 'method))->getAttributes(); > > $cacheableNode =3D $attributes[Cacheable::class] ?? new > > Php\Parser\Node(AST_TYPE_VALUE, 50); > > $cacheTime =3D $cacheableNode->value; > > > > // For more complex things, like expressions or constant, runtime > > evaluation can be performed. > > $codeNode =3D $attributes[Php\Contract\Requires::class] ?? new > > Php\Parser\Node(AST_TYPE_STATEMENT, '$this->value >=3D0'); > > $code =3D (string) $codeNode; > > $result =3D 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=C3=A9sar D. Rodas > Open Source developer > +595-983-161124 > PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6 > > > --089e01538610ee1064050f342acc--