Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107135 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 32483 invoked from network); 16 Sep 2019 07:59:34 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 16 Sep 2019 07:59:34 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id A9C112CD1C4 for ; Sun, 15 Sep 2019 22:36:22 -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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) (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 ; Sun, 15 Sep 2019 22:36:22 -0700 (PDT) Received: by mail-oi1-x229.google.com with SMTP id k9so6297082oib.7 for ; Sun, 15 Sep 2019 22:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=Wwdpy/Vw0nebJu7O0QDB/2+sy2jtDKVu6BtE84WOTv8=; b=lz5dhw7sisx8KNGqkxtftNVN6o7bNm5FJjdZ/QPuNxE4OpuRDCOxaHRPoOjCpV0L1V LHAfnoDYoYyf8MaG4njQUToB7bBE17ju4LNQwX+aFLbyem1odWJ4RDyj/vhCWChLL91y Oxn9T4DfZKVKhcUuHeq1ubMFVajz3J/8pLa/i2wEOFHDS7RKrsP+wGBZCn7RCK4FEQkn +TjUN60kf/B/36904ANh5YP2NJgu5XlHIwQoXRN3/kHfFHKEi6PDDEua0ovl8I2FD0uQ lLK7e6AAGSaoD1BzWP4f4qorLAD40QDYZ4Rcr9I0XspKdIVZw13zazkIbrf8GWpTBARR pzmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Wwdpy/Vw0nebJu7O0QDB/2+sy2jtDKVu6BtE84WOTv8=; b=nAVDRhp7xDkScHMz9nRMKirmqCKitQyj9GmJFROq9xRtyRzMhZcNFD7ZJYJzCByKnF 6xVb/UxsvcL8+cI2eePs81qMFqxLd7vkuYEMQohY57t6m6KHAIUS5s0KhYLRz2RpsqwL O0ZE38D2uPJamvhqgvuB3njgdsoaE+eElMEQhyftBa4f9NctQeZsB0QLlwtEiFq+tjJr k6IVteIUVkWUmzvvP2KnBGgYeB4G/A3e9tkmep94QE1rXoghyDW1K6KwQAv33TTBQcqi UFsSVtLTo0yKImJkZpvfXNbo1k/HzdAuLdDfV+1PPp08VAHc7xoDX91uk21XHZvpn3S0 +/mQ== X-Gm-Message-State: APjAAAUjzyIK5O2U08yuuFIulZ1vvxMwTt0piQvHDJIDB9osYO8fL68z 4t1pJY9ZY+qUQjcA5AjWyS9kWDcMn87a2EYys5FMQA== X-Google-Smtp-Source: APXvYqxuPVjHR7HXh0JvKMjcmECdhVk0eQoxbZGx4Zia7h5yAx1JYpZBpKQBkk7INIyRfu6Uzjmb01haDgZY6zHCR3A= X-Received: by 2002:aca:5f46:: with SMTP id t67mr12646372oib.42.1568612181415; Sun, 15 Sep 2019 22:36:21 -0700 (PDT) MIME-Version: 1.0 Date: Mon, 16 Sep 2019 12:36:12 +0700 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="000000000000dd20520592a4fb44" X-Envelope-From: Subject: [Discussion] `ifset()` language construct From: webdevxp.com@gmail.com (Kosit Supanyo) --000000000000dd20520592a4fb44 Content-Type: text/plain; charset="UTF-8" Hi Internals I don't have permission to create RFCs but I would like to propose/discuss new language construct called `ifset()` which is syntactic sugar to null coalescing operator with rhs value `null`. The goal of this proposal is similar to Andrea Fauld's proposal ( https://wiki.php.net/rfc/unary_null_coalescing_operator), and the chosen keyword is similar to historical discussion `ifsetor()`. Here's an example. $result = $a ?? null; vs $result = ifset($a); $result = $a ?? $b ?? $c ?? $d ?? $e ?? null; vs $result = ifset($a, $b, $c, $d, $e); As you can see `ifset()` does not make code much shorter but the main goal of this syntax is expressiveness not shortness. someFunc( $arg1, $arg2, $longVariableName1 ?? $longVariableName2 ?? $longVariableName3 ?? null, $arg4, ); vs someFunc( $arg1, $arg2, ifset( $longVariableName1, $longVariableName2, $longVariableName3, ), $arg4, ); I know that this proposal is highly unlikely to be accepted because it just does same as `??` but in different way and it introduces new keyword (we don't have any new keyword since `yield` in 5.5) and, furthermore, I did search through github and found some projects using `ifset` as function name (https://github.com/search?l=PHP&q=ifset&type=Code). Here's the patch: https://github.com/webdevxp/php-src Cheers --000000000000dd20520592a4fb44--