Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82837 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14988 invoked from network); 16 Feb 2015 12:44:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Feb 2015 12:44:08 -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:36119] helo=li147-116.members.linode.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C5/F3-29513-716E1E45 for ; Mon, 16 Feb 2015 07:44:07 -0500 Message-ID: <54E1E607.5020206@rodas.me> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rodas.me; s=mail; t=1424090644; bh=TMxdZIDIrVgvNVKrGCce/N7NALH8vF+wsEkgTEhL42M=; h=Date:From:To:Subject:References:In-Reply-To:From; b=Vzw2sNE8crJJpRTu+VaBn3W/cibZL472I6tqZAqzpRZ/qOXTYl02c4BCfc5BTiKqx q24K944GCXRF7uYY+vtnmOpSnWiADKZorsbyyec72wZSjw/HVmRccB0ZYaJseMtvWf rlEO+OhkblI7po76cY9V1LyIAVkVtyfsYqunkAJ8= Date: Mon, 16 Feb 2015 13:43:51 +0100 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="RXWfct9FAaf2cLEaLfIRh9RfLQIqiXxwC" Subject: Re: [PHP-DEV] Annotations in PHP7 From: cesar@rodas.me (Cesar Rodas) --RXWfct9FAaf2cLEaLfIRh9RfLQIqiXxwC Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 conte= xt. >> 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))->getAttrib= utes(); > $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? --=20 C=C3=A9sar D. Rodas Open Source developer +595-983-161124 PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6 --RXWfct9FAaf2cLEaLfIRh9RfLQIqiXxwC 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 iQIcBAEBAgAGBQJU4eYHAAoJEBWKAzbHBwqmOYkP/2o2hnz+4LX75pkWh8glrDog SPbkF45wHVTnvYVLNXUdI3IfjwsrCuz/NlW3UdS7Zzvg0Ii5r68LLmKBSK7/KQEV l+bmMKPEsa8LWTiEddQ5w9YM5fnTrapM/MIAXTWrk13p86iffqz4pl0XnF9lpf4E l/U7G7xNR4XdCBQvRS9bodK4vT4CUh7WrCZ2YlDjdbyAPcS99QwZ11r8Nf0D+gY2 IsZY4fj+tJ01HPSWhJcjp65efaAk2poc8ZPxXBNS7dvUBC+uIifKvjU6LIwq+HFp 1ef++HTfb4POAh2KdvqgpOecyRdyKRVea5uxTs2u+FhYkdUG/rhhNLacI6+9fQQy R7k9Zq1nLj222LpfSZf5X/x+UvcKP0Z0tx26VmcefqwxDBUHosxrA3zuboF/IlrN gDNffjgxFF+7X/KDG6DrDhQ723J9fVlGZY9S+HXAnTJ3UgeiTjOWMVKGMMk6XxAt 0Bf9cm+au6gQQ3gbx8ENtBiw3YwAfFSU1jbJ766otJntSHfAebqLep4rRrVWkylE dS21AxLFHuWqjHJUjqMHG+1AYIjQ+3d6NY8S6yScdQMSwxp9AZMNdbAm57Mcgx13 RRzJMFo7MDwDuA3WjN4W5P7EX+1IlQSfkPpQDdVGKgRJIHJTmjqcBTP28IVEHtHC i5psaV+Hn+UrefzrV1zg =iIgN -----END PGP SIGNATURE----- --RXWfct9FAaf2cLEaLfIRh9RfLQIqiXxwC--