Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93698 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13023 invoked from network); 1 Jun 2016 21:09:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jun 2016 21:09:32 -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.213.48 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.213.48 mail-vk0-f48.google.com Received: from [209.85.213.48] ([209.85.213.48:32979] helo=mail-vk0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 47/88-63812-B0F4F475 for ; Wed, 01 Jun 2016 17:09:32 -0400 Received: by mail-vk0-f48.google.com with SMTP id r140so45346442vkf.0 for ; Wed, 01 Jun 2016 14:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=yG58TIo4QQRIJleCF/HtHwOtegNK238nLNO0OzvRMMU=; b=RYzSSonpFYi+q5TkGgY2UKvpcaXBEj9rco9Q0qoCM4XgHZA/AlZErdJWmqk/4g+Kro +jz8Rsn20pJKVMJzJh179axHHSkskuQFDQV41Tjy5W3s3U5IuTMid0kfO7J2llUyRyGM 2aVe/h3kw7SZMxMyreYKw14sB+0hmYojGNIi9axByd0Ww2pSxVeeylu4ai2FEze68iOM ibvbK6tE2C1lrOWYbL+7kwEIw7lIbdyfPB40lhBoDOUzJZmyIoII0AGW1Z54h+WhXm5J +4orMgnuETzqMQ5uDIHQpuKCCijnoGMLZLBjWTRo8lQyWMOTLlAF76BinN82KZdJTbBJ G1Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=yG58TIo4QQRIJleCF/HtHwOtegNK238nLNO0OzvRMMU=; b=alYCBChEvra2vfGfhhV+Ozxj1O7t772bgNPkI4pD4F/HUkq1X51El5kp4eXzCTSqj7 A4n+EaeXauqThHqaN2eDF0/L6i0zgs8HO/gWDYI42IuJryTNJx5FLwGfIlQsCeptBhrI 2i3lRQUnGx/tQtzX9Tpxeyjq5CmiqkF/OKifZ9GqADEmexn7r6QYrh/P7Xf6ec4Vecl3 lXysZR/tsv4dCevrc3NBkJ4E6r70yESdqSaAe82IRxLkbr6onAkBte78IR5dpwuOkyus 3fK4J41LHO90lvPbQsrqqlB4keftpPccR85p9eWkGvUuBx9mnmcZ2I30qnZXcY42EBi8 KRrA== X-Gm-Message-State: ALyK8tLBBWfYMaONq1uxuwDg/Ntd2FKoBsAR7+e+jlPlSXByPkqArDDrsk1feCkhtlFLvt65vHWua5XlFG4dLA== MIME-Version: 1.0 X-Received: by 10.31.10.82 with SMTP id 79mr2619480vkk.67.1464815368419; Wed, 01 Jun 2016 14:09:28 -0700 (PDT) Received: by 10.103.88.81 with HTTP; Wed, 1 Jun 2016 14:09:28 -0700 (PDT) In-Reply-To: <574F487E.6030009@lsces.co.uk> References: <574EAD78.5000402@lsces.co.uk> <574F487E.6030009@lsces.co.uk> Date: Wed, 1 Jun 2016 23:09:28 +0200 Message-ID: To: Lester Caine Cc: PHP internals Content-Type: multipart/alternative; boundary=001a11457d64b25ac105343de7e1 Subject: Re: [PHP-DEV] Set object properties inline From: rasmus@mindplay.dk (Rasmus Schultz) --001a11457d64b25ac105343de7e1 Content-Type: text/plain; charset=UTF-8 > The drive to make everything as 'static' as possible misses > the whole point that PHP is a DYNAMIC scripting system. I think that line of argumentation is pretty outdated - it may have been valid many years ago, but by now, PHP is not purely dynamic; far from it. It's a gradually-typed language, and more so with scalar type-hints recently added, and typed properties and nullable types coming up. The drive to enhance the static side of the language doesn't miss a point, nor does it take away from the dynamic side of the language - the whole point of gradually-typed languages is the ability to choose between static and dynamic in each situation. This tendency to "defend" the dynamic side of the language, as though static features were somehow an "attack" on dynamic features, befuddles me. These two sides of the language do not compete with each other - they complement each other. Just interjecting a general remark here, I'm not commenting on the proposed feature specifically. On Wed, Jun 1, 2016 at 10:41 PM, Lester Caine wrote: > On 01/06/16 21:09, Jesse Schalken wrote: > > 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: > > Which was the start of the discussion when 'arrays' were being pushed as > a 'solution' back in the PHP5.1/2 timescale. > > > 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. > > Hard coding the list of names just so you can add 'static analysis' is > only one style of working. My set of array keys come from the database > schema, which is another way of defining and typing your parameter set. > > > 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.) > > If your starting point is an array of database fields which are enhanced > with the relevant type and constraint attributes, then 'performance' > starts from that base. That was the base we were working on 15 years > ago, and trying to replace that with hard coded 'PHP only' code does not > remove that. The drive to make everything as 'static' as possible misses > the whole point that PHP is a DYNAMIC scripting system. > > -- > 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 > > --001a11457d64b25ac105343de7e1--