Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67289 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2735 invoked from network); 3 May 2013 11:32:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 May 2013 11:32:22 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.212.46 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.212.46 mail-vb0-f46.google.com Received: from [209.85.212.46] ([209.85.212.46:48842] helo=mail-vb0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 35/D1-26044-440A3815 for ; Fri, 03 May 2013 07:32:21 -0400 Received: by mail-vb0-f46.google.com with SMTP id 10so1259879vbe.33 for ; Fri, 03 May 2013 04:32:18 -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=nqivUiFn8tccNWjNymtGsJQTcMEh9CCsRaAsdEOyRZc=; b=kpIRjGp307P4uARNgCqKsmo/oMKtaq7pQQzpIgxAyBIJ5/uCpo0rO8uL1j0FLVU7gS qj9WJQ7Bl60gk7h09cxjnaOJAIvBHICjJdovcPA+3Uo8NiahkOm9uNJxyVuxHSqjZ4Rr EyFERlKgxjtqo/lktHy1PfRdseDsgWAQIyqmpLxalXSGLy8AqAPUXfPupMJdsIbauIJ4 yTfTFDO5Hkobi4r39RCtm2tTyFhmDEdPsCY3HgBcqSrmbn6jZk15LUzyQado60036cGB C0Mj4yVH02VbCHdLxf+/TEOLpFXmaVVtyaOfpuSCqHYeL7jTJzyzOvo5CBA/gpkt1ig1 4cVA== MIME-Version: 1.0 X-Received: by 10.52.18.173 with SMTP id x13mr2969347vdd.121.1367580738218; Fri, 03 May 2013 04:32:18 -0700 (PDT) Received: by 10.58.28.134 with HTTP; Fri, 3 May 2013 04:32:18 -0700 (PDT) In-Reply-To: References: <6245ED6B-2BF7-47B7-80C0-D3B3D8E0B312@strojny.net> <51803086.6020002@sugarcrm.com> <518030FD.5030504@lerdorf.com> Date: Fri, 3 May 2013 07:32:18 -0400 Message-ID: To: Lazare Inepologlou Cc: Bernhard Schussek , Adam Harvey , PHP internals Content-Type: multipart/alternative; boundary=bcaec50405c01a822a04dbceb4a5 X-Gm-Message-State: ALoCoQmN8an5KuXPJZ6pTOEM9wM6YVppXbFag3702iCCHiRtihG59M3hDxTKSrRLdFqoFXne6Xer Subject: Re: [PHP-DEV] property de-referencing From: rasmus@mindplay.dk (Rasmus Schultz) --bcaec50405c01a822a04dbceb4a5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable That's an interesting spin on the idea, but it takes away the ability to lazy-evaluate an entire path - now it works only for the last property, which may not always be optimal or desirable. I don't personally have a problem with putting the operator before the expression, I think that's clear enough - it's clear enough for the // and # comment operators, for example, that the entire line will be commented out. If you don't agree with that, maybe it should be a grouping operator, e.g. a start and an end symbol? Even harder to find characters that won't conflict though... On Fri, May 3, 2013 at 4:24 AM, Lazare Inepologlou wrot= e: > > > 2013/5/2 Bernhard Schussek > >> 2013/5/1 Rasmus Schultz >> >> > > One could >> > > write a PropertyReference class right now with literally the only >> > > difference being the lack of a builtin operator (ie new >> > > PropertyReference($obj, 'prop') versus ^$obj->prop): the fact that >> > > nobody seems to have done this in a major framework I know of sugges= ts >> > > that there isn't a strong need for encapsulating the indirection >> > > beyond the $obj->$prop syntax that's worked forever. >> > > >> > >> > Look at the Symfony form-builder example - encapsulating the >> indirection is >> > *precisely* what they're doing: the object reference is stored in the >> > form-builder, and property-names are added subsequently. >> > >> >> As the developer of the Symfony Form component, I would like to clarify >> that this is not true. At the time the property reference is stored, the >> object it refers to is not (necessarily) known. You could build an >> abstract >> form definition for "Author" instances, but only later instantiate a for= m >> for that definition with a concrete object. So to be really useful in a >> form context, property references need to be separated from object >> instances (something like "^Author::$firstName" could work). >> >> Second, it is important that references can span multiple nodes in an >> object/array graph. In Symfony, we built the PropertyAccess component fo= r >> that [1] which allows references like >> >> "authors[0].personalDetails[firstName]" >> >> which translates to >> >> ->getAuthors()[0]->getPersonalDetails()['firstName'] >> >> or >> >> ->authors[0]->getPersonalDetails()['firstName'] >> >> > > I have an idea regarding the syntax. The suggested ^ operator is > troublesome, because it does not make clear that whatever follows will no= t > be evaluated. This becomes even more confusing when dealing with multiple > nodes, as the example above, where part of the expression has to be > evaluated. > > Let's have something different: > > $obj~>property > MyClass::~property > > > This syntax can be easily applied to multiple nodes, without confusion: > > ->getAuthors()[0]->getPersonalDetails()~>firstName > > And it can be applied statically: > > Author::~firstName > > > > > Lazare Inepologlou > Ing=E9nieur Logiciel > > --bcaec50405c01a822a04dbceb4a5--