Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110052 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 42467 invoked from network); 6 May 2020 23:13:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 May 2020 23:13:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1418C1804C3 for ; Wed, 6 May 2020 14:48:23 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 6 May 2020 14:48:22 -0700 (PDT) Received: by mail-qt1-f171.google.com with SMTP id o10so2973391qtr.6 for ; Wed, 06 May 2020 14:48:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=OGyubuvHZCQPdSVnkHCrnHooFNy2eJWe8MlKnGOEAHI=; b=XaEUUeJRpeMU/0eRwDInoodQHXeaEaVFcZb1BbfE7Gq/22JKDK+F5DBRLWENe7Yw9j rO0FqY4B9THICoDtRcMqdpqIqRjZ+Qy7cw2bGt1N+myYUypGJb1xJEdf++XYld3a2DmV cYv8zrzUrCIw7dWOLw7WvI34zqkKm9FyTrJzKecjvcQ963ij3NtblPrLKAKlEcc8RuZB fCG5I/IetbaLsnp2J5Yq5n8GtV90X4JE9/TxVHhCRuFlGTT2OyPHUdQf7cc6rxiZs02y mDlLbpCmuGbEHNGkcjGf+zflj3DEjfxGrGVJtK6YeGMPEtQwYvBhw8UMpVOeemvf/Mnm MKQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=OGyubuvHZCQPdSVnkHCrnHooFNy2eJWe8MlKnGOEAHI=; b=UHNWnHHneHWpOyizhcTuRfSO/LGcngNw2Lxp6Qi3LrbtedKS7iPEPtc8k3UZ2G5blv V6aoliyRK4lFyIQAeQL9rkmlQxOzdmQqPbWAp5Ef3871YSbyKmTWHKoaNGd9OdzXurHJ Ah9FveqzoXU73Y/YwGZOjxTCT+qF2ts3wyzX+8U84SEoTSBk6aZjWjHmTrq63JnzVirb K3s3nHIESGHvFe8Qs/Z73giZUzYuD87Her2uw099evrZoktcyniWVVISmuR7S8Eilbkv u083x0LWqzR1/FULNphymdOo9sYPpG5qUjr1g2Cnd2IEm5eVOxcN9iNYyemlR6w6zu1d So4A== X-Gm-Message-State: AGi0PuZRY9iiFcwe38WpGcB9hBXUF+8tQvQ5hMLm/6fCPva4s3GBLTyW AusI5gDrV/IieQBhN0pNDlqQmA== X-Google-Smtp-Source: APiQypLFwSx2ZFPXOvY4+RYqeL3K6XqeYMg+Eo87BxYln9OoXudLDAnpA7FLEAFyDP5tXamPu+bT7w== X-Received: by 2002:ac8:4a06:: with SMTP id x6mr10976570qtq.163.1588801701768; Wed, 06 May 2020 14:48:21 -0700 (PDT) Received: from ?IPv6:2601:c0:c680:5cc0:f08a:3d5:11af:903? ([2601:c0:c680:5cc0:f08a:3d5:11af:903]) by smtp.gmail.com with ESMTPSA id m7sm2609722qti.6.2020.05.06.14.48.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 May 2020 14:48:21 -0700 (PDT) Message-ID: <44B0AB58-2993-403F-B75C-124AB26B6875@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_7203CE63-2ED2-4182-9F82-E2D40C4BF4DB" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Date: Wed, 6 May 2020 17:48:20 -0400 In-Reply-To: <54c5f8f0-1526-53df-0912-0b00e0e54bc3@gmail.com> Cc: internals@lists.php.net To: Rowan Tommins References: <1C09C0A9-1DA4-4753-8E5A-A739D52DA0B3@newclarity.net> <54c5f8f0-1526-53df-0912-0b00e0e54bc3@gmail.com> X-Mailer: Apple Mail (2.3445.104.11) Subject: Re: [PHP-DEV] [RFC] Parameter Blocks (vs. Constructor Property Promotion and Named Parameters) From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_7203CE63-2ED2-4182-9F82-E2D40C4BF4DB Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On May 6, 2020, at 4:14 PM, Rowan Tommins = wrote: >=20 > Hi Mike, >=20 > On 06/05/2020 20:48, Mike Schinkel wrote: >> Consider simply what we might call "Parameter Blocks." Since PHP = always expects a parentheses to follow the function or method name it = should be possible to opt-in replace it with a brace-enclosed block of = parameters instead since it would be unambiguous and this no conflict, = and no need for new keywords. >>=20 >> The following illustrates how it my be used by repurposing an example = from the RFC: >> ... >=20 >=20 > I'm not really clear what this example is showing. It seems to be the = same as the one in Nikita's RFC, but with the punctuation changed = slightly from "(public $foo, public $bar)" to "{public $foo; public = $bar;}" That is exactly the case. > I'm not sure how this changes anything, or how it relates to named = parameters. Could you expand on the problems you see this solving? Let's look at it like this, with line numbers that would be reported in = the case of syntax error: 1: function foo(public $foo, public $bar) {} vs.=20 1: function foo { 2: public $foo;=20 3: public $bar; 4: } {} -------------- Now, consider the following two examples. On which line would PHP report = the error? function foo() ( public $foo,=20 public $ bar ) {} vs.=20 function foo { public $foo;=20 public $ bar; } {} With two parameters, no attributes and no PHP doc the error is pretty = easy to spot. ----------------- Now consider a constructor w/20 properties/parameters, 5 attributes = across those properties, and a total of 100 lines of PHP Doc = interspersed and it becomes a lot more difficult to deal with if it is = one virtual line =E2=80=94 as PHP sees it =E2=80=94 than spread across = 125 lines. Much harder to diagnose a syntax error. ----------------- It is for the same reason I avoid code that instantiates a single array = literal that spans hundreds of line of code and instead create methods = to append small array literals to the array. If you have one really = long virtual line it makes it much harder to identify where syntax = errors occurred. Having one long virtual line also limits what features can be added in = future versions of PHP. If you need help visualizing it I mocked up an example from actual = function that is in product that was written by someone else before I = joined the client's current team: https://gist.github.com/mikeschinkel/faaee3fc8ccc2371c7200f3d634289c4 = -Mike= --Apple-Mail=_7203CE63-2ED2-4182-9F82-E2D40C4BF4DB--