Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67230 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65187 invoked from network); 30 Apr 2013 23:15:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2013 23:15:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.128.180 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.128.180 mail-ve0-f180.google.com Received: from [209.85.128.180] ([209.85.128.180:39879] helo=mail-ve0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 17/8C-18873-6A050815 for ; Tue, 30 Apr 2013 19:15:51 -0400 Received: by mail-ve0-f180.google.com with SMTP id pb11so872124veb.39 for ; Tue, 30 Apr 2013 16:15:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=cVdwIRswnUcqYq7h6cmCaBKOAyCyVvZrMweWl8pj5dk=; b=IcCfx2GIL8BZe8bVL+U17p9wJMIwtPfo2/SitO8+cs5602WN1fG9BYBADDEpw2yVfQ edhR0fInDWIbeZnNlLvw50wUqklhMZQ2/8jHAQyVAumFZiFqxU3OsiNKIpMqxPryF7da KBtdArqX5dkSa4Bbpqx9Ra9CL8MpGWLDD8SaS4LKX8bE97imgden1EaT+yk0BSWEZWKG 3sBzC3yKsC3/M3LmpGoJdqVP7VEB1HCbFAC6Bl2zejjY36j5tyaVmyLJpKn5B9JoHPm1 GEhz8Mpja7HNeBQ1HEDWyOUsPL5AeJp87vk7AY4AGevJgtfWWDHeszCQt/9y2T71SMbF ViVg== MIME-Version: 1.0 X-Received: by 10.220.156.8 with SMTP id u8mr163914vcw.24.1367363748368; Tue, 30 Apr 2013 16:15:48 -0700 (PDT) Received: by 10.58.28.134 with HTTP; Tue, 30 Apr 2013 16:15:48 -0700 (PDT) In-Reply-To: References: <6245ED6B-2BF7-47B7-80C0-D3B3D8E0B312@strojny.net> <51803086.6020002@sugarcrm.com> <518030FD.5030504@lerdorf.com> Date: Tue, 30 Apr 2013 19:15:48 -0400 Message-ID: To: Lazare Inepologlou Cc: Rasmus Lerdorf , Stas Malyshev , PHP internals Content-Type: multipart/alternative; boundary=f46d043c817a80564704db9c2eae X-Gm-Message-State: ALoCoQngTy7xclmVrVnA5Mh0Yl1iHWfa0NRoNLDr6ZaMNKiXRdl1Rgpg+6YnqECl1zyXbr4Ewwbq Subject: Re: [PHP-DEV] property de-referencing From: rasmus@mindplay.dk (Rasmus Schultz) --f46d043c817a80564704db9c2eae Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I suggested something similar earlier: http://marc.info/?t=3D136327849600002&r=3D1&w=3D2 However, I withdrew that idea, because I came to the realization that, for practical applications, you usually need the object-context coupled with the member-reference to do anything really useful. A form-input abstraction, for example, needs the object-context to reflect on the class, the property-reference to reflect on annotations (maybe) and of course the property-value, plus the ability to apply a posted value back onto to the object-property. The proposed feature facilitates all of that. At the risk of starting a separate discussion, the recently added ClassName::class constant provides a way to statically reference a class, which frankly has very few practical applications in comparison - the need to reference properties is usually much more prevalent and repetitive than the need to reference a class; assuming your classes have more than one property each, heh. The feature as such is also somewhat crippled, since what comes out of it is a string and not a class-reference. It solves the problems of static class-references of course, so that's positive - but where's the much more critical property-reference counterpart? Because this feature overloads class-constant syntax, there is no obvious counterpart for properties. It seems pretty short-sighted. If referencing a class statically is necessary and important enough to make it into the language, why are property-references considered less important or valuable? Try to think of these features in terms of completing or complementing the fairly limited static side of an otherwise mostly dynamic language, rather than as features intended to solve a specific programming problem as such. I think there is still a pretty strong case for static property-references, but since any new language-feature is generally a pretty hard sell around here, I'm letting this one go for now. The immediate impact and benefits of static object-property references ought to be a much easier sell - it has pretty broad applications, and can probably replace a lot of simple inline function-closures, and eliminate a lot of double-arguments (object and property-name) from many popular/mainstream libraries. If you disagree, please explain by example. I've already put a lot of time into thinking about this and explaining it pretty carefully. If you're opposed for more than personal reasons, surely you can offer more than a flippant one-line backlash? :-) On Tue, Apr 30, 2013 at 6:20 PM, Lazare Inepologlou wro= te: > > > 2013/4/30 Rasmus Lerdorf > >> On 04/30/2013 01:58 PM, Stas Malyshev wrote: >> > Hi! >> > >> >> I'm proposing we need a way to statically reference an object propert= y >> - >> >> the object property itself, not it's value: >> > >> > You probably have use case for that, and it should be pretty easy to >> > write a class that does that, but why it should be in the language? It >> > certainly doesn't look like something sizeable portion of PHP devs wou= ld >> > do frequently. >> >> It is certainly not worth overloading the XOR operator for. >> >> -Rasmus >> >> > In C#, they had the intention to introduce the operator infoof(...) to ge= t > the reflection, not only of properties, but of virtually everything in th= e > language. They abandoned the idea because it is really hard to do that fo= r > overloaded functions and they did not want to do all that work for a half > baked feature: > > > http://blogs.msdn.com/b/ericlippert/archive/2009/05/21/in-foof-we-trust-a= -dialogue.aspx > > However, PHP does not have overloaded functions, which makes things > significantly easier, so maybe it is worth examining the idea. > > > Lazare INEPOLOGLOU > Ing=E9nieur Logiciel > > --f46d043c817a80564704db9c2eae--