Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78675 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12432 invoked from network); 4 Nov 2014 20:03:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Nov 2014 20:03:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=ua.san.alex@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ua.san.alex@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.195 as permitted sender) X-PHP-List-Original-Sender: ua.san.alex@gmail.com X-Host-Fingerprint: 209.85.213.195 mail-ig0-f195.google.com Received: from [209.85.213.195] ([209.85.213.195:58329] helo=mail-ig0-f195.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 62/71-02095-10139545 for ; Tue, 04 Nov 2014 15:03:14 -0500 Received: by mail-ig0-f195.google.com with SMTP id l13so19489iga.2 for ; Tue, 04 Nov 2014 12:03:10 -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=4FlKn32XQt/sSj6x7pBlHJMeX/nWbQ4hxJVDsjbWGSQ=; b=fL3R1Q+WW5XhE9sYQA1PMLi91mqP9HeDgVl23UKs70c/mdBJx0iiOEmI/7jQe5uCui He3UZOWGn4USNgzi8p0zSIz82nXgGjogE0RZdmwKVoRFBeUrsE31iVEHicr8zSvIsQ9n F/KI8AUq8YuITYnPCCHJSYp2QzP3JUP6Ab6rdGjkHwjYZStxDNutZYZipGgmHZkYp1WN LaRhSnXWUjt9Ojq73l/nWaKFeFQAF8MxHL3wtkb3WSl3XFgOV5hld4inRbjb1atBiEE0 b4VwjCS3D7WPY0rJgB/PIzBwWrwlCnZu+Avm/5HAH/gC/+1CckVJpx/2ELSDuLZ4V4FO LegQ== MIME-Version: 1.0 X-Received: by 10.107.132.168 with SMTP id o40mr19004701ioi.50.1415131388407; Tue, 04 Nov 2014 12:03:08 -0800 (PST) Received: by 10.50.98.68 with HTTP; Tue, 4 Nov 2014 12:03:08 -0800 (PST) In-Reply-To: <54591A76.8070302@sugarcrm.com> References: <5457AF2F.90808@php.net> <5457BDB7.8070701@garfieldtech.com> <54589A8D.3020607@sugarcrm.com> <1C3F4FA3-ABD5-4F6F-A898-F63AC1C723D5@ajf.me> <54591A76.8070302@sugarcrm.com> Date: Tue, 4 Nov 2014 22:03:08 +0200 Message-ID: To: Stas Malyshev Cc: Andrea Faulds , Benjamin Eberlei , Pierre Joye , Levi Morrison , PHP internals , Larry Garfield Content-Type: multipart/alternative; boundary=001a113f31c8b774c405070df3aa Subject: Re: [PHP-DEV] Annotation PHP 7 From: ua.san.alex@gmail.com ("S.A.N") --001a113f31c8b774c405070df3aa Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable If this is difficult, you can do in PHP 7.0 simple realization annotation/facades, in versions 7.x to develop and refine. Most importantly, define the syntax and semantics annotation/facades, for a version of PHP 7.0 Demand in annotation/facades is very high, ~80% of all popular frameworks their use, it is really what you need PHP developers. 2014-11-04 20:27 GMT+02:00 Stas Malyshev : > Hi! > > > The approach for annotations that I like best would actually be not > > annotations, but Python-style decorators. They=E2=80=99re very simple, = but > > very powerful. They would allow you to do annotations, but also add > > extra functionality to functions. > > For python-style decorators, at least the way they work in Python, we'd > need to organize our function tables differently, as Python just > replaces the function with another one while decorating, and I'm not > sure it'd be as easy to do with PHP. > > > Which would be equivalent to the following PHP code: > > > > $myfunc =3D function myfunc() { # function source code here }; $myfunc > > =3D some_decorator($myfunc, foo, bar); > > Not really, because functions work differently in Python and in PHP. You > can not just replace a function in class's function table with random > closure in PHP, at least easily. > You'd have to convert all such functions to closures (or something that > can be both, maybe) and have the engine be aware that function table now > can store closures. And, also, inheritance may get a bit weird there. It > would be very powerful, but it may not be very simple to do. > > Also, it is a major overkill for what annotations are commonly used - > attaching a piece of data to an entity. In Python, decorators are very > powerful for modifying function behavior (i.e., attaching pre/post > conditions to functions or doing some things phpunit does is really > easy) but it is too much for just attaching data. > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a113f31c8b774c405070df3aa--