Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107027 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93214 invoked from network); 13 Sep 2019 00:20:30 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 13 Sep 2019 00:20:30 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 090812D1FC4 for ; Thu, 12 Sep 2019 14:56:29 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Thu, 12 Sep 2019 14:56:28 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id 4so26087019qki.6 for ; Thu, 12 Sep 2019 14:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7muE76BF7F8aFe1TwTakvGD+CZXZomw9TTfB9z7OJIM=; b=AnaSF9cwTzdaK+NVDdjMZ+AQrwZ4EiPoQcRv+mrTyRLX8iAJiPYp6dT0HqZbnRUMdX 7cLxQv1A/buYAsuKPrvXxBqKMXFxG1giyWNJ44YzKTavnjpBY1307NpNb5XCq/z63xOe 1toOcBI9uGKbdduCPy7OsDaR9UJem5ra8ZvdKkOZy28Uz0A7WKaUh69TDuMKBa4VX2bJ xz9/hBberR9Ct2OeIS3dg4cIMk22D4TPJ4Fvnl8jnfGEnRfRA5yAnMDzo/M4ECTjEmjm 9GDQlYvGXo3w3RNdcOF1moql0uuD1FuMAQBN8ePcJm0mqICJonYPvhTWwxw1K9Jazs8R cuVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7muE76BF7F8aFe1TwTakvGD+CZXZomw9TTfB9z7OJIM=; b=rTimrt+IpDLXZIHkElU+4FLpe2HGmVD4cRuGeBmiAhYShx71tVIzJTpv2I2eJGAzw8 xLgR+13zTE6saxDXnz1RhN6rziBpDRsUcoNT/XlQe9nJGX6Z/OLWEqYVj2WByWNV58sv u6hVeO7uupS4qn7qMhxJCWlHmyRWiPE/Ez+LPB8IekiH95KRuNhEp+hC4qawYBdGYZgy 27fmc52C0dy+4HpMQsV0nXnSOqx2LCuxfSEyhPnbj/ztyZf5QuRsc5GShphFl0GcFCDj 1XOPAQQ6fhxa6c5G+kS1zhIknEhBriNDJiqmCYOPwJCav8CwTc1ds82X+1q1KXBiHAi9 c1Dw== X-Gm-Message-State: APjAAAV9zMEwExTmeuDL0DuuWRW5H2Sudl4IKKJFLH1d5Vh448StIyOM uvPgGC+vONNsLMvtCp0kROh8QiFNDJWrLA== X-Google-Smtp-Source: APXvYqxt6PYi50aPOD3Z2IY7jJ01sig8F3Qj/MSZ3VbDRkzSbVeYpsWejfVnKVUaYzeF9kjxERz9+g== X-Received: by 2002:a37:bd45:: with SMTP id n66mr42074750qkf.272.1568325387548; Thu, 12 Sep 2019 14:56:27 -0700 (PDT) Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com. [209.85.160.178]) by smtp.googlemail.com with ESMTPSA id v26sm16050535qta.88.2019.09.12.14.56.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Sep 2019 14:56:26 -0700 (PDT) Received: by mail-qt1-f178.google.com with SMTP id c17so12162047qtv.9 for ; Thu, 12 Sep 2019 14:56:26 -0700 (PDT) X-Received: by 2002:a0c:a9d3:: with SMTP id c19mr3820489qvb.172.1568325386378; Thu, 12 Sep 2019 14:56:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 12 Sep 2019 23:56:14 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Marco Pivetta Cc: Arvids Godjuks , Rowan Collins , PHP internals Content-Type: multipart/alternative; boundary="0000000000008c258205926235ca" X-Envelope-From: Subject: Re: [PHP-DEV] [RFC] Reclassifying engine warnings From: andreas@dqxtech.net (Andreas Hennings) --0000000000008c258205926235ca Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable In the past I suggested operators like ??++ ??+=3D for this purpose. But the [? $key] is even better, because it makes it explicit which array keys we expect to already exist and which we don't. $var[$k0][? $k1][? $k2]++; This is great but the second "?" is redundant isn't it? Marco Pivetta schrieb am Do., 12. Sep. 2019, 16:26: > > > > On Thu, Sep 12, 2019 at 4:02 PM Arvids Godjuks > wrote: > > > > > > > =D1=87=D1=82, 12 =D1=81=D0=B5=D0=BD=D1=82. 2019 =D0=B3. =D0=B2 15:33, M= arco Pivetta : > > > >> Hey Rowan, > >> > >> > >> > >> On Thu, Sep 12, 2019 at 3:30 PM Rowan Tommins > >> wrote: > >> > >> > For instance, for undefined array keys, what if we had an operator f= or > >> > "initialise and retrieve", such as $foo[? 'bar']. Then we could > simplify > >> > ugly code like this: > >> > > >> > if ( ! isset($foo[$key1]) { > >> > $foo[$key1] =3D []; > >> > } > >> > if ( ! isset($foo[$key1][$key2]) { > >> > $foo[$key1][$key2] =3D 0; > >> > } > >> > $foo[$key1][$key2]++; > >> > > >> > > >> > With something safe but succinct like this: > >> > > >> > $foo[? $key1][? $key2]++; > >> > > >> > >> $foo[$key1][$key2] =3D ($foo[$key1][$key2] ?? 0) + 1; > >> > >> > >> > > This message contains a healthy dose of sarcasm. > > > > > No sarcasm intended: question is about the verbosity and length of a > *proper* (correct =3D no warnings/notices/errors, matches type expectatio= ns) > checked solution, and I provided a simple one-liner that is both readable > and correct. > > You can make what you want out of this, but there was most certainly no > sarcasm. > > Marco Pivetta > > http://twitter.com/Ocramius > > http://ocramius.github.com/ > --0000000000008c258205926235ca--