Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113241 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 16568 invoked from network); 23 Feb 2021 19:30:39 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Feb 2021 19:30:39 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E482E1804C3 for ; Tue, 23 Feb 2021 11:19:10 -0800 (PST) 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.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 ; Tue, 23 Feb 2021 11:19:10 -0800 (PST) Received: by mail-lf1-f41.google.com with SMTP id e7so13039134lft.2 for ; Tue, 23 Feb 2021 11:19:10 -0800 (PST) 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=zVg+BSjsdIfCnkuLMTQKjVY9Po0E5mxPm6Ea4iimpTE=; b=Rh/YSOKxVDcLARoBTnXbWA6ajDcqcXjNMXknV1i4rfpllr8ZyQJMmlzfbPZrN1YgbS kIockcvsSDWtA0VvzxFlmNH3Mj9K2hJs69PqRm7OpUQ9rdonqtrMxX5xnJm3pra+AZ7w 7iR4fFIRw4BtHyn12lLo5VO6Y3eST6wn3OdwH6amupB6ShHelKSrrc58/KiOJmox/FH5 zY47vu3PQLBXbbsBlFwsT2frI7UJ3gIK1mqOZ7hMQgFMkVc4oV5dX0ef4vTOZ6aHx8zT 9/gp5qpYtZd1THqMYovPXUCf98FAepy6XsGTSLz9y3eflChOu8iOkTDlGTPRFeA/FRKK iECw== X-Gm-Message-State: AOAM5335XjSDXNnUHgnBIvgWp0VWFgxNS5YhDnY2oo6gwHqEL7MTkB6C pNN85ZG7GAqaPW0xuieJdO1gdsnGLQHS0hmDanxIJA== X-Google-Smtp-Source: ABdhPJys1mhuLhlGwXbp5tYQzNwAHkN4c7XKngL+TALhdAFWmZuGdGgYsPbakUfDkJV5t5ieJF4MPPFETj1E4WtbFtY= X-Received: by 2002:a19:48d0:: with SMTP id v199mr16526475lfa.55.1614107947113; Tue, 23 Feb 2021 11:19:07 -0800 (PST) MIME-Version: 1.0 References: <2664e2ef-b965-407c-90fc-77480846a3ad@www.fastmail.com> <84020328-b623-bca1-0c9c-0f7195e08d23@gmail.com> In-Reply-To: <84020328-b623-bca1-0c9c-0f7195e08d23@gmail.com> Date: Tue, 23 Feb 2021 13:18:56 -0600 Message-ID: To: Rowan Tommins Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000d1377305bc05ca11" Subject: Re: [PHP-DEV] Inline conditional that returns null if falsy From: pollita@php.net (Sara Golemon) --000000000000d1377305bc05ca11 Content-Type: text/plain; charset="UTF-8" On Tue, Feb 23, 2021 at 1:05 PM Rowan Tommins wrote: > > On 23/02/2021 18:41, Albert Casademont wrote: > > Sure, it's not a big deal having to write the ": null" but it doesn't add > > any value > > On the contrary, it adds an important piece of information: that the > default value is "null", rather than "false", or "0", or "new EmptyValue()". > > For instance, it doesn't seem at all obvious to me that this code should > produce a null: > > $items = []; > $itemCount = $items ? count($items); > > I might be more convinced that "null" is the "natural" value if the > left-hand operand was only checked against null, not "falsiness": in > that case, you can read it as "if it's null, leave it alone". I'd still > be inclined towards "too specific to use up more syntax", though. > This sums up my feelings on the topic very well. The proposal seeks to remove clarity of intent to save four characters. Hard nope as presented. -Sara --000000000000d1377305bc05ca11--