Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82889 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37281 invoked from network); 16 Feb 2015 21:07:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Feb 2015 21:07:24 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.173 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.212.173 mail-wi0-f173.google.com Received: from [209.85.212.173] ([209.85.212.173:39083] helo=mail-wi0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8B/FF-36518-A0C52E45 for ; Mon, 16 Feb 2015 16:07:23 -0500 Received: by mail-wi0-f173.google.com with SMTP id bs8so28630273wib.0 for ; Mon, 16 Feb 2015 13:07:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=NnPnmHIL4hl4sUCr87A4zA5KDsCc2tcCv/P3kuNsLVU=; b=BQA3zwye3R8jyx4k8F/EONZutLws6fiH4uGA2V3n+urQMhhtPmDfnxL2EorZ3FQfdE zKmn7fWP63tueF6vnUwpxufISvy1+WeMJA8y3duj6sBxJMdAFxMlv3ZW9SV3S50J53eJ SZgC8Jria0MJLbR/nG3w13l643wV2XadVjMY34jxZGwykjuiKK5Hp7jaEoSkTXLROfNu qmW4396NpQMyvI6/ncANc73gZe9z2/Afh10GO+2YPPhgJWCDm1MTps9aurjr1MSrjqyt jlG7dXt3ZkaC/iaaQQfMRjEYnrsjwKZR3WtYWaRY37TBl3urF5GlMjy49cPDyO29pRYL lD/Q== MIME-Version: 1.0 X-Received: by 10.194.71.175 with SMTP id w15mr48471947wju.16.1424120839749; Mon, 16 Feb 2015 13:07:19 -0800 (PST) Received: by 10.27.10.168 with HTTP; Mon, 16 Feb 2015 13:07:19 -0800 (PST) In-Reply-To: References: Date: Mon, 16 Feb 2015 22:07:19 +0100 Message-ID: To: Dmitry Stogov Cc: Benjamin Eberlei , PHP Internals , Guilherme Blanco , Pierrick CHARRON , Alexander Lisachenko , Pierre Joye , Zeev Suraski , Andi Gutmans , Joe Watkins , Yasuo Ohgaki , Sebastian Bergmann , Stanislav Malyshev , Rasmus Lerdorf Content-Type: multipart/alternative; boundary=047d7bfcf000c5462a050f3af87f Subject: Re: [PHP-DEV] Annotations in PHP7 From: nikita.ppv@gmail.com (Nikita Popov) --047d7bfcf000c5462a050f3af87f Content-Type: text/plain; charset=UTF-8 On Mon, Feb 16, 2015 at 10:02 PM, Dmitry Stogov wrote: > > > On Mon, Feb 16, 2015 at 11:05 PM, Benjamin Eberlei > wrote: > >> >> >> On Mon, Feb 16, 2015 at 12:07 PM, Dmitry Stogov wrote: >> >>> hi, >>> >>> During discussion of different ways of implementing "Design by Contract" >>> we >>> got an idea of using annotations. >>> >>> BTW: annotations are useful by their own and may be used for different >>> purposes. Support for annotations was proposed long time ago: >>> >>> https://wiki.php.net/rfc/annotations >>> https://wiki.php.net/rfc/annotations-in-docblock >>> https://wiki.php.net/rfc/reflection_doccomment_annotations >>> >>> HHVM already implemented similar concept >>> >>> http://docs.hhvm.com/manual/en/hack.attributes.php >>> >>> I made a quick and dirty PoC that shows how we may implement annotations >>> in >>> PHP7 and how powerful they may be : >>> https://gist.github.com/dstogov/dbf2a8f46e43719bd2c2 >> >> >> How about not exposing the AST, and then the userland can pass context to >> a method $reflection->getAnnotation($name, $context); >> >> https://gist.github.com/beberlei/0dc36d4412b8e3454912 >> >> That way AST is not exposed to userland. >> > > Your example handles just particular use-case. > I would like to provide a general solution. > > Thanks. Dmitry. > Could you provide some more info on how you would imagine this to be used for the DbC use case? As far as I see, this would require injecting code into the method body based on the annotations. Does that mean that annotations handlers will get the chance to modify the AST of the method itself during compilation? Or how is this supposed to be realized? Nikita --047d7bfcf000c5462a050f3af87f--