Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49735 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67921 invoked from network); 16 Sep 2010 20:58:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2010 20:58:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=jussiava@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jussiava@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: jussiava@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:42388] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E4/31-15036-E05829C4 for ; Thu, 16 Sep 2010 16:58:55 -0400 Received: by qwb8 with SMTP id 8so1404675qwb.29 for ; Thu, 16 Sep 2010 13:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=+oh8RnSduJ/mAhLZ3dsgtTX5ZM2o66A7wIBlXOHolg4=; b=JC1VBJIu2yu/dzrua5+i93ZD31x0JOCN+2P9kK1BmwoYqI+aQwa/qEyzBZg146Gmfv hv84nweGXo6hrTBfznIl/a+FGu2iGkqSXejOojVgRe3YXpeaJ8LuDkvzvYqDUXep82fL /Ndhlh0NIMOrDEL6n81m9a4l6at8xLYoeR/Zg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=wNh/dETlXikyhq/VKZzB9r4BGzOIQhvwDhUf2JXN67mB20Won+OttXpj3ryLblekZC shu1ricYt26gqEqdym+URuXD3ZIcefMZAI4BM1QD7SUUoTVeHlbOFp0515sjOXM0ObUc b/R8UkYtko4WV80qC0Wdxzh9ZmEb2889LyK5Q= MIME-Version: 1.0 Received: by 10.229.68.13 with SMTP id t13mr2711671qci.101.1284670732275; Thu, 16 Sep 2010 13:58:52 -0700 (PDT) Received: by 10.229.39.80 with HTTP; Thu, 16 Sep 2010 13:58:52 -0700 (PDT) In-Reply-To: <4C9258C1.9080207@sugarcrm.com> References: <39505F13-655A-43AF-941E-77750B7F7201@gmail.com> <4C8FC695.2060800@sugarcrm.com> <4C8FD72B.1070108@sugarcrm.com> <4C906333.4030204@sugarcrm.com> <7.0.1.0.2.20100915085504.17eab4d8@zend.com> <12617cf66ae07d7a2fd79a293ed69b85@beberlei.de> <4C9095D5.1050206@toolpark.com> <000001cb5511$467949f0$d36bddd0$@com> <64b4e95cac44ee297a12601d26a5453c@localhost> <4C9258C1.9080207@sugarcrm.com> Date: Thu, 16 Sep 2010 23:58:52 +0300 Message-ID: To: Stas Malyshev Cc: "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re: Re: PHP Annotations RFC + Patch From: jussiava@gmail.com (Jussi Vaihia) Good reminder, thanks! Implementation would indeed require support from PHP, say: // magic-method __decorate implies that __construct would return $this->__decorate(func_get_args(), $f); and enforce @ as annotation-syntax class Dec1 { function __decorate($args, $f) { return $f; } } class Dec2 { ... } @dec2 @dec1 function foo() {} means this: $foo =3D new Dec2(new Dec1(new ReflectionFunction('foo'))); Perhaps ... $foo =3D @Dec2(@Dec1(new ReflectionFunction('foo'))); On Thu, Sep 16, 2010 at 8:49 PM, Stas Malyshev wro= te: > Hi! > >> Could PHP as a language be kept "pure" by first implementing python >> decorators*, then implement annotations using a purpose-built >> decorator? > > No, we can't have python decorators because unlike Python PHP functions a= nd > classes aren't first-class objects. In Python, this: > > @dec2 > @dec1 > def func(arg1, arg2, ...): > =A0 =A0pass > > means this: > > def func(arg1, arg2, ...): > =A0 =A0pass > func =3D dec2(dec1(func)) > > However, you can't write equivalent code in PHP. > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227 >