Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82843 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25924 invoked from network); 16 Feb 2015 13:07:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Feb 2015 13:07:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=cesar@rodas.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=cesar@rodas.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain rodas.me designates 109.74.200.116 as permitted sender) X-PHP-List-Original-Sender: cesar@rodas.me X-Host-Fingerprint: 109.74.200.116 li147-116.members.linode.com Received: from [109.74.200.116] ([109.74.200.116:36179] helo=li147-116.members.linode.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 25/16-29513-A8BE1E45 for ; Mon, 16 Feb 2015 08:07:23 -0500 Message-ID: <54E1EB82.8040404@rodas.me> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rodas.me; s=mail; t=1424092038; bh=uHPkbFxKwIC1Csw/SusI3Ww8+gL3MN0vsX/qjq0GiZ0=; h=Date:From:To:Subject:References:In-Reply-To:From; b=pAa1wxupNby0zkLsn7zyzsf+6R02lU0tL9oNpQhSe7n3rQL+cvRHkxQ0D7OsUz59c OeiScYqD71cNNzkRwqlgqmgPz9/s+iBoCOfU5b0FHPJZI0Ye13m+HcbPUjpkMtTQ7U xQG5eyw9HQ6rtBIqJKTOZiZfuDZZhbf0Rd7BVZgA= Date: Mon, 16 Feb 2015 14:07:14 +0100 MIME-Version: 1.0 To: internals@lists.php.net References: <54E1E607.5020206@rodas.me> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ACODstwNtlJjhELR6D8wVBcKsqLB3pmmM" Subject: Re: [PHP-DEV] Annotations in PHP7 From: cesar@rodas.me (Cesar Rodas) --ACODstwNtlJjhELR6D8wVBcKsqLB3pmmM Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 16/02/15 14:00, Dmitry Stogov wrote: > 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. That is awesome. I would vote for a yes and I'd like it out ASAP (I would adapt my own annotation parser to read *also* this annotations). I don't know however how hard it is to get it out on 7.0 but _I'd like_ to have it. Cheers, > > 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 functi= on >> is >>>> necessary like evaluate_ast(...), but that requires passing the >> context. >>>> many many open questions and as nikic points out this should probabl= y 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 userlan= d? >> 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 >> >> >> --=20 C=C3=A9sar D. Rodas Open Source developer +595-983-161124 PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6 --ACODstwNtlJjhELR6D8wVBcKsqLB3pmmM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJU4euCAAoJEBWKAzbHBwqmBv0QAJ+cAyLiBoxlV4PWiJpSWTal 0sRNWaKIeBJUADKFGd0BJmYmeslIw9+UTYL8QdG+cXHxukKebbFo7V0EipI/uMQt ditzmbl9YyVMEqrCFDt8yEo6YDzHM5E/jlEEdbybsGBl172nFIR123kywUTvx3IP eyMRM1DtijNV0+bHzEHjMEulm8K9WrXBF7UG+IYuscanIt+BVEynXHh5Bc+eq80U 3jd832jOqtzw2OymEh8DOOkeAmoBjtIOGxNPxtlLZjlLO7YvC7qkd38TSGAqdBHA b/47rM6rv4xQ4wbR4J4wqJE7fEFWwfcgFEptyAN0K+sadTj+jkKMYyEqXVAJBPDY PWTs+m/YcXUhB2SjfZJtIzFeOo1TqOIJa5vl2p0/0jW13Es6awsKaKsrFaV6tkgw cz+QmNchUfHK2enxLrgXB6y78f+ueGLzD0Ty2UUsH+4XUKC3Upkysft0hbyNXbGO /9Mn8GCAWTq2S3V1kUU7KSeLYgqs8shZ0UPNRwJTsux4//E1y/qv17Cz6KWWvexk CfP7HsiOjzDisp9KC6eMqFWGT+KmtW8prg6+JOfNMO+9sdd6JfQb7nm2mu5Duf6N n6OHGWesbIRNJ55A75nJ13DCf3Zr6atOsgViMsSRLJ+KRTFKk7+gyNbiWYhrTFh3 wU2+ynmn4yDqfLcnENvu =ilEB -----END PGP SIGNATURE----- --ACODstwNtlJjhELR6D8wVBcKsqLB3pmmM--