Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61914 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65587 invoked from network); 1 Aug 2012 11:54:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Aug 2012 11:54:20 -0000 Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 209.85.215.170 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 209.85.215.170 mail-ey0-f170.google.com Received: from [209.85.215.170] ([209.85.215.170:55089] helo=mail-ey0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EA/65-32875-BE819105 for ; Wed, 01 Aug 2012 07:54:19 -0400 Received: by eaao10 with SMTP id o10so1662974eaa.29 for ; Wed, 01 Aug 2012 04:54:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:from:to:cc:references:subject:date:mime-version :content-type:content-transfer-encoding:x-priority:x-msmail-priority :x-mailer:x-mimeole:x-gm-message-state; bh=BTQaU67RRlHpom1D8hcS+oXhQSnIkWu4nugIxBjYsWY=; b=TR4n3brqWW9Ek28JTLU58yqU2CIHQrf6oGZ5sf0TvBmPMlbAimJoi0S1AzOf8MOCLM EcDCDo2nCsat+CMcBq83Cuf1eXaSssg5Car1wb3L1GKL8dlyZtmiydrEdYFDUy1bi/tu TAohJ7NPjomzldRTz3Td8eJ42POL3eDtauuiwcz1BXDFbkSS4GNWc8i3dPlaGMHvyoNJ 2a+/iSNHWV4PvEmPhQB4x42jYKyT+wLoR/nnP8xJA6YLuOcydsWeetm9V3xW6AEY6i40 gSgN3vcy34XY1nBMUmuAYKl37wg/LNztr4wlUV6uwXlibFgDEgia4lyL/ooe8BfkxLS/ AgPw== Received: by 10.14.178.67 with SMTP id e43mr22037394eem.44.1343822055775; Wed, 01 Aug 2012 04:54:15 -0700 (PDT) Received: from pc (79-100-60-213.btc-net.bg. [79.100.60.213]) by mx.google.com with ESMTPS id o47sm8295220eem.0.2012.08.01.04.54.13 (version=SSLv3 cipher=OTHER); Wed, 01 Aug 2012 04:54:14 -0700 (PDT) Message-ID: <2125641B4C7D4D6E8616F86C9C5563D2@pc> To: "Stefan Marr" Cc: References: <232501B15F7F4B3197123F219370E36D@pc> Date: Wed, 1 Aug 2012 14:54:05 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Gm-Message-State: ALoCoQmO/abMVjsRWe4SKQTmX07JIGBhwef4oKoq4PIiGCCk85CQNhuv73iG9IrcuDD044/+4aCM Subject: Re: [PHP-DEV] Traits behavior still up in the air in 5.4 From: sv_forums@fmethod.com ("Stan Vass") > The methods in the class have *always* higher precedence. > This is the same 'overriding' behavior used for inheritance. > From my personal perspective, changing this would lead to a major > inconsistency with how subclassing works. Hi, I've subsequently read your RFC carefully and saw some of those items are by design. However while they're by design, the end result seems rather confusing I should say. While I'm glad the RFC was shooting for consistency in general, traits are not subclassing. Therefore aligning the behavior of features for vertical reuse with features for horizontal reuse seems somewhat arbtirary to me. The use cases for overriding methods like this seem sketchy at best. What is the use case, and how are those use cases more important than the confusion caused by allowig this? >>2. Using "as" syntax when importing a trait does NOT rename a method, but >>creates an alias CLONE, the original method still callable. >> Proposed behavior: the original name should be only accessible within >> the trait and its methods, not from the class methods or by calling the >> class instance's methods from outside. > Again, this happens to be 'by design'. > PHP is a rather dynamic language, and we happen to have things like > $c->$foo(); where $foo is a string. Renaming is technically not reasonable, and would also lead to major confusion when metaprogramming is used. Can you please explain how are function names by variable at all related to this? $object->foo() and $object->$foo() aren't even related in any way semantically. If a conflict exists while grafting a trait, the original method will be overshadowed silently and the method will be only accessible by the alias. The entire idea of aliasing is to avoid a conflict with an existing method of the same name. While if there's no collision, it's accessible by both. So in practice it works by chance. How is "working by chance" in any way aiding meta programming? >> 3. Properties silently collide in traits and classes. > Please read > https://wiki.php.net/rfc/horizontalreuse#handling_of_propertiesstate > carefully. > > Again, this is intended behavior. > If you want to be notified of such collisions, please use E_STRICT. I've read them carefully now, but there's no solid reason given for this behavior, or why the proper behavior only exists in E_STRICT. I can't really see "state is a complex topic" as a reason why trait property collisions are handles inconsistently with method collisions. >> 4. The documentation says static propeties can't be defined by traits. >> Yet they can. >> >> I don't know what's the bug here: a doc bug, or a code bug. For >> consistency, static properties should work, if instance properties work. >> Nothing is gained supporting it half-way. >Could you please point me *exactly* to the paragraph where we have >something written about static properties? I do not see that I wrote >anything special about static properties in the >RFC. And I do not find it >in the docs either. static properties should work like normal properties. Sure. From the manual page for traits: "Static variables can be referred to in trait methods, but cannot be defined by the trait." This paragraph is then following by a code example using function-static variables as what seems like an example for a replacement for static trait properties, strongly suggesting the former aren't supported. Yet they are. The RFC seems to also give examples of method-level static variables, and I honestly can't see how this is related to traits or trait/class-level members at all. Stan