Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93693 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3141 invoked from network); 1 Jun 2016 20:09:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jun 2016 20:09:49 -0000 Authentication-Results: pb1.pair.com header.from=jesseschalken@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=jesseschalken@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.43 as permitted sender) X-PHP-List-Original-Sender: jesseschalken@gmail.com X-Host-Fingerprint: 209.85.214.43 mail-it0-f43.google.com Received: from [209.85.214.43] ([209.85.214.43:36644] helo=mail-it0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 51/B6-63812-B014F475 for ; Wed, 01 Jun 2016 16:09:48 -0400 Received: by mail-it0-f43.google.com with SMTP id e62so104368996ita.1 for ; Wed, 01 Jun 2016 13:09:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=nDWnTu2clh8mRlId5TQpKv715awQcP1MQ0eV1YbrDj8=; b=oNByice4RTjHQs5eyKHsyvcoFAmGYDCLPk+YXYrTzTWbw2Kx1O1eZLT93/cvi6maO9 wHergwJNv9qnuoxrF7tbpcoy5Spr/IY66ps6ui7wklN0ED+FFm7F47Dz7gxqRsZQiokL sQyiD/BNI1a2p1uqx0BYojzw9PW190jR7RtsfZwCfixv2PgQpizvf4cLHC4nGiJNaiNI +9qdHz/cgCE14o9wxelKlPQ4PtitICiuxym9BsHG+KJRgMktCfR5qDIcznYIkVEvcZbb D2kdyGHJsHgODV0VGonmQ4YeG4y3YeMqvozTEYMwkGMKl68NNaykqnnGAj4z+6S5XRQ0 32HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=nDWnTu2clh8mRlId5TQpKv715awQcP1MQ0eV1YbrDj8=; b=Dy6jeFIcoEyI6Kr5MJ4pkBnDLi2nHjdU5fXzCtCSR9JJqV+V3aOswlOy85gGBUW7j+ LVTK1YvBjg/FBOXotsIzYfx6WWyRD1ORYjmT5sH6tFerIVj9b7T6lP0Y1Hl65wYPWtFt jzhmAhQMOjzBZeZ/3g5AMb3mBlGYzvFlS5LN/eJDEpSmTQy5OlE2PNHRPM21PDIePw9Z zxH2gU5xV8mzD8bT9Htgg/0qI4KLaaxDR9TM2cPkenS3eDX+ghMupU9CER3KepqlUP9v QWZlDmkIKiWPYg+GplipaQTFyAiS0wR3zLbyTGUHah1a4AuGG4rF0qUXBwT6NjPg/vPV RnlQ== X-Gm-Message-State: ALyK8tLisN6QwFUq/w+FO5lgy3KcJThOcMzyYMuPZOOG1gcI8KWZY6sOWnl52K0x1TY1cQZjgKYfVt70i4VxuA== MIME-Version: 1.0 X-Received: by 10.36.208.135 with SMTP id m129mr7929839itg.56.1464811784945; Wed, 01 Jun 2016 13:09:44 -0700 (PDT) Sender: jesseschalken@gmail.com Received: by 10.79.111.208 with HTTP; Wed, 1 Jun 2016 13:09:44 -0700 (PDT) In-Reply-To: <574EAD78.5000402@lsces.co.uk> References: <574EAD78.5000402@lsces.co.uk> Date: Thu, 2 Jun 2016 06:09:44 +1000 X-Google-Sender-Auth: Oy6kxJhcF1vdPzAipiODoRlGVHY Message-ID: To: Lester Caine Cc: PHP internals Content-Type: multipart/alternative; boundary=001a1149a9541b355a05343d1296 Subject: Re: [PHP-DEV] Set object properties inline From: me@jesseschalken.com (Jesse Schalken) --001a1149a9541b355a05343d1296 Content-Type: text/plain; charset=UTF-8 On Wed, Jun 1, 2016 at 7:40 PM, Lester Caine wrote: > Morphed into simply passing an array to the constructor ... > > $static1 = new Data\StaticVariable( array( > 'name' => 'variable name', > 'value' => $unknown1, > 'functionName' => 'blahFunction' ) ); > > // className defaults to null > > Of cause the short cut at that time was to drop the names and simply > count the variables, but what this replaces is all the complications of > named parameters and allowed passing objects in such as '$unknown1' > This works fine to remove the temporary variable but compromises two things that I think are very important: 1. IDE tooling and static analysis. An IDE can't autocomplete property names as array keys, because it doesn't know the array keys are properties, nor can it ensure that the properties actually exist, are visible, and are being assigned the correct type. If I do a "Find Usages" on a property, it may appear to be only read and never set, implying I can remove the property and replace all the reads with the default value. Any static analysis tool would have the same trouble. 2. Performance. The code spends time building a temporary hash table just to loop over it, look up each key in the object's property table, check visibility, check type, assign it, and discard the hash table. That's a lot of overhead just to assign some properties. With a dedicated inline property assignment syntax, a normal bunch of "assign property" bytecode instructions can be output and the PHP runtime will cache the property offsets and assign them directly, and can elide the property type check if the optimiser knows it will pass. HHVM can even burn the property offset right into the compiled machine code. That's *way *faster. (At least that's how I was told it works when I asked here a couple of weeks ago.) > -- > Lester Caine - G8HFL > ----------------------------- > Contact - http://lsces.co.uk/wiki/?page=contact > L.S.Caine Electronic Services - http://lsces.co.uk > EnquirySolve - http://enquirysolve.com/ > Model Engineers Digital Workshop - http://medw.co.uk > Rainbow Digital Media - http://rainbowdigitalmedia.co.uk > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a1149a9541b355a05343d1296--