Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93012 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87515 invoked from network); 30 Apr 2016 23:20:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2016 23:20:49 -0000 Authentication-Results: pb1.pair.com header.from=danack@basereality.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=danack@basereality.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain basereality.com from 209.85.161.170 cause and error) X-PHP-List-Original-Sender: danack@basereality.com X-Host-Fingerprint: 209.85.161.170 mail-yw0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:33754] helo=mail-yw0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E0/63-58459-0DD35275 for ; Sat, 30 Apr 2016 19:20:49 -0400 Received: by mail-yw0-f170.google.com with SMTP id t10so232730782ywa.0 for ; Sat, 30 Apr 2016 16:20:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=BDvXPbOOPWID6mffrmV7hc6Z0mzvaelVa1bI8ihD5kw=; b=l7qsg0RXIprq2dMc4IkuBWNEjRFRLlgOktfgytS4+hkUsatrhsf2sbMQ5sApX0m9Ka YX0U1s6bT2WscC1KnBgMaKTjOuYrfNsr2cJ7K8MKzoNXavT20tLppHPnZauwmsTYf5BQ GbKOKI5h1AYmwbl7+e9w4XBUBaUhTqjAhVZw3m1/JGKot1LBsdpshMTxXxCHtXBD33Bv ysK+Qdklf3li9TQJdnDUtmtLyGOZoEcvE7680Wm08z4RbyXCGg/uE4iNXaMbcPCYDoa1 yOXo49jJyb7y0e0DymAm4Qnsh8/QhAKozABvpI2rbpQ1HvTenfR/lpdzNndlek21gAIr 5HGw== 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=BDvXPbOOPWID6mffrmV7hc6Z0mzvaelVa1bI8ihD5kw=; b=ULamlc1W5F5ZbMoqKlmKJZ2DhcpCh553v0EpK6Q8F+YA7ZcpUpr2YSDXdgNWQMjUL9 YxChWr5wjNjiuPzeOmydF1mTkkY5GPiG5tGZnp1/r4MA5pmVSS/4oeSHXeLZfmV3Bexp L6Qgf3p8XgSqx10X8s081ln7jDjtYBaTs+f4uQF0I3QBvlZJeqkOC+7QDKu6falCGzQY 2FQt2mwMcVAbC6wi9zkdN9Y+RmbZ+ATPVSyUA2xN5Klg0Pceo8XA1ll7XK2wJZXi/Xt6 EDm0baleZ5uy1FBPx9ok+fhKTpXArfVhJpLrr/uOK1BGZirRx3qvAvfpwD1Ccar8aFHv /LoA== X-Gm-Message-State: AOPr4FW8Z4dL6eMn1lGy2uccCSoiBtpeva2MrgJBLgBqOTMzFwVKUpyxxOkbhIMgsz6TbOGyPnDa9cK5itLBIQ== MIME-Version: 1.0 X-Received: by 10.13.209.197 with SMTP id t188mr17335525ywd.33.1462058445323; Sat, 30 Apr 2016 16:20:45 -0700 (PDT) Received: by 10.37.91.10 with HTTP; Sat, 30 Apr 2016 16:20:45 -0700 (PDT) X-Originating-IP: [2.99.239.93] In-Reply-To: <5723F4C4.6080207@garfieldtech.com> References: <5723F4C4.6080207@garfieldtech.com> Date: Sun, 1 May 2016 00:20:45 +0100 Message-ID: To: Larry Garfield , Sara Golemon Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC] Pipe Operator From: danack@basereality.com (Dan Ackroyd) Hi Sara, I have to take exception to the section of the RFC titled "File collection Example", where you take a block of code and re-write it to be more readable, using the RFC's syntax. However, it is not the proposed new syntax that makes the code more readable - it is solely due to writing it in the correct order that makes the code more readable. This can be done using current PHP syntax, so that the code is: $dirEntries = scandir($arg); $files = array_filter($filesAndDirectories, function($x) { return $x !== '.' && $x != '..'; }); $fullPaths = array_map(function ($x) use ($arg) { return $arg . '/' . $x; }, $files) $fileInfo = getFileArg($fullPaths); $ret = array_merge($ret, $fileListInfo); Using the proposed new syntax to rewrite it without the intermediate variables like this. $ret = scandir($arg) |> array_filter($$, function($x) { return $x !== '.' && $x != '..'; }) |> array_map(function ($x) use ($arg) { return $arg . '/' . $x; }, $$) |> getFileArg($$) |> array_merge($ret, $$); Does not now show a marked improvement in readability. Showing the benefits of an RFC by comparing 'apples to oranges', is at least to some extent 'pulling a fast one'. Do you have any examples where the original code is not terrible, that show an increase in readability? (By implication, I am not persuaded by the PSR 7 ones.) Larry Garfield wrote: > The absence of an intermediate variable name does not inherently hinder readability/debuggability (nor does its presence inherently improve it). I disagree strongly, the presence of intermedite variables does help the code be more understandable. It gives semantic meaning to the steps in involved in the process, as well as giving variables that can be watched in a debugger. If people want the excitement of not being able to figure out what the intermediate variables mean, then they can already do so by using terrible variable names. From the first "PSR7 Example", we could write the code like: $v = getGlobals(); $v = parseRequest($v); $request = buildPsr7Request($v); If you truly believe that not having semantically meaningful intermediate variable names, you would have no problem with code being written like this, right? Personally, I always use semantically meaningful variable names, as they make life so much easier for any person who needs to read the code. cheers Dan