Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123837 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 71C601A009C for ; Tue, 25 Jun 2024 18:23:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719339872; bh=26vdQUVZKNtLeTLY+teMgytdRIUnUcVnD64yT2EjH98=; h=References:In-Reply-To:From:Date:Subject:To:From; b=NCm4hYMzmZPven2OIO6bxbjLOuFFtLSIoTf7q0q1qok4o2iiaeujZ5tWICvhre9Hd i1qjN8aqcnvPcsGY+LkJ2tZZ1a73ZaT+ShCalezubby+f2epVMPcc9ONFjaZtnMiQM Gd4hnAJSvJJps41LsBYgOWK4WTKjoQpYPcQiRS2SRyCfUSJoCoARvQOgK4h30C4l06 QVuZWyZ3/r06bYl0qrJZYgupYPFSvdezgpgWxoYjpy4rqoLevH1cEUdw02Vjs/lONd PENYImcydEufIupOuOo+POhEh9khlPzOTKJlExr9AACorDdzT6RaZ3T8OwKFkvxCE7 /6yXoSTNbrc1w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5E72C180B58 for ; Tue, 25 Jun 2024 18:24:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 25 Jun 2024 18:24:30 +0000 (UTC) Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6f95be3d4c4so2580657a34.3 for ; Tue, 25 Jun 2024 11:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719339793; x=1719944593; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=26vdQUVZKNtLeTLY+teMgytdRIUnUcVnD64yT2EjH98=; b=HK8iCS5Mu0eUpi5DrCU5DapzRcJGSUYrpktrZR9c+ENGeU5ydTJN294bo70Kbw0ewO +bkJG36+4QmjvW9EaTHybkl7+iOCLZRG3B2ZBfsegKE3h/WaTIAiknMQeTkeyoz/NcDl W/oftYE1opWhtexo0gUvjWQNciOVSPqKTRgmYVvfVobMmjRTelF17wF+eXuFBFbigJgr jnYhnhqBqrnQMZ7aNPWxl+zqFgBIN75apjoqL0YlJ43CHPvRXdBeCPfxecT+wXy9seh2 qSipS+rnlsaznOH9z0rVciPPB4yKrVwITyOlzG3PfobXNMHDE9Bt4aeU2Yp1Ejup3lFR JYIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719339793; x=1719944593; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=26vdQUVZKNtLeTLY+teMgytdRIUnUcVnD64yT2EjH98=; b=bkJvSWU2DhG/7feNMDd/aGoytOJ6F6YndInpoq2NS0SMztT7BnX/hr9t+0AiJQQlaf Tm5VYsAiAbK+j7tlevVrodmOdhCuDhwbEaDy+Ui4JqwA+zN8yuhNlNMZciMtardVkn4/ Q/FhaLC5SiCEk9+eXbEKXPhUeQx21D6DePzTTzXp4EvsbajLsdwM2TcT73yxQ70FmRhb miQmtmyOHrsJPZRRqxWNYXzsuDBtZslQbJoPbE+OWuQq2nylke+ZxotfJqTwVT0HQRrX 1rhAwTDPKoRk+UOHYuZ98Z0DzEPP51GZr2RiRzMkNvDZ8a32ZfnaNG9Mu8bdh4mghvU9 LKUA== X-Gm-Message-State: AOJu0YxPO2dQhZYrI2REjQKGpMDDFlhgRJ9yMQ0HlTJjFUexm9nIAZWT WRNCxGog6OJ3I2qqRVjEOWpOV8hFEaYBYrs1w7eSmee8rOK1Xb1avxTopaBCPNhTokCgSaal1eK w14EnzvsjwjNmY1tQEUzF2IjbjQQp5hDczc+zdg== X-Google-Smtp-Source: AGHT+IHqW3DSDxq5Q0CHlzua5Yon04v/0KFWAWki3pqeBLLh1Xutxq65MbH2sJsKbz5SpKWZQiZyRbQDWOvdCoRkDd4= X-Received: by 2002:a9d:7410:0:b0:6f9:a850:dd49 with SMTP id 46e09a7af769-700b127577dmr8834630a34.30.1719339792826; Tue, 25 Jun 2024 11:23:12 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <2a6b92eb-d5e9-4a1a-9548-a068ac42ebd2@app.fastmail.com> <1E295280-619B-4490-B53C-0899B64F9215@chaz.works> <97a93ae2-5202-47eb-bf51-ec1e976ea765@app.fastmail.com> In-Reply-To: <97a93ae2-5202-47eb-bf51-ec1e976ea765@app.fastmail.com> Date: Tue, 25 Jun 2024 20:23:01 +0200 Message-ID: Subject: Re: [PHP-DEV] [Early Feedback] Pattern matching To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Rob On Tue, Jun 25, 2024 at 9:05=E2=80=AFAM Rob Landers wro= te: > > On Tue, Jun 25, 2024, at 01:20, Ilija Tovilo wrote: > > On Mon, Jun 24, 2024 at 9:54=E2=80=AFPM Robert Landers wrote: > > > > To be honest, this is one of the smaller concerns I have with the new > > syntax. There might be some misunderstanding here, though. A > > non-existent key is NULL, always has been, and always will be. > > This is just not accurate. Inexistent indexes are not null in PHP, > they are undefined. PHP implicitly coerces undefined to null, because > undefined is not a value accessible to users. The same occurs when > accessing $undefinedVariable. For arrays, this fact is observable > through `foreach`, warnings when accessing the index, and likely > others. > > This is a bit like telling someone who fell off a ladder that they didn= =E2=80=99t =E2=80=9Ctechnically=E2=80=9D fall, instead the Earth and them p= ulled at each other until they collided and the ground + body absorbed the = energy. > > While yes, you are =E2=80=9Ctechnically=E2=80=9D correct, what you descri= be is essentially unobservable from the context of the running code (unless= you turn the warning into an error/exception). For all direct accesses of = array values ($arr['key']) an array is infinitely full of nulls (I have act= ually depended on this property at one point for a bloom filter). If null array values were indeed unobservable, then [] would be =3D=3D=3D t= o [null] (or at least =3D=3D), and a foreach over [null] would result in 0 iterations. But neither of those are the case. > So yes, `[?'foo' =3D> string]` and `['foo' =3D> ?string]` are indeed > different. The former accepts `[]`, while the latter accepts `['foo' > =3D> null]`. > > Are they actually different in practice though? That was my point. After = the =E2=80=9Cis=E2=80=9D in both cases, you=E2=80=99ll have to use null-coa= lescence to retrieve the value. For all intents, they are the same resultin= g code. If you can show a difference in the resulting code and how it is an= improvement, I may be inclined to agree, but I can=E2=80=99t think of one. Sure. If a null value were to mean "not set", then ['foo' =3D> string] should accept ['foo' =3D> 'foo', 'bar' =3D> null], which is absolutely observable if the code assumes it won't see any additional indexes. Ilija