Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111377 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 30181 invoked from network); 8 Aug 2020 16:59:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Aug 2020 16:59:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9320E1804CD for ; Sat, 8 Aug 2020 08:58:34 -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.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-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 ; Sat, 8 Aug 2020 08:58:33 -0700 (PDT) Received: by mail-lf1-f46.google.com with SMTP id j22so2549630lfm.2 for ; Sat, 08 Aug 2020 08:58:33 -0700 (PDT) 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=G+3FsDX7QqcNh6hnVo2ItJwnI+Vtg4Q1u94FMs0QEMg=; b=FTjkfL1iMwQE6cXDimZCDUoQmlsKoA8PuHgtZ1jIW0kHuhV+x/hwDNKryq90rZh/KM cOH+ytoNey01yZqNAm/ODwmhk2Uja4LXD+bEAttHG4nlnxMB+5bT0Sp1kvIq+4MyWm+O OdI1Mek+5mN7Rb53tA+vPmKafp5aoKtLMJjsrjJVv8P3s46dyf9CDfmyvg1YFgTzsUQK Xs+BI9K98s2Aw9aBrIQbYe3tJHGT/vZMhyiwIfvkSa1yFaqbqGLfg+A2CElV2RpezCSS 2ydiQOVof4CTIr4rl+WIzq3gxFl6Wt9h8vRwA/70v0FnC0983ZWGgH3AoDa3CzdeHEHx Y12g== X-Gm-Message-State: AOAM530S8CSzVRoeag+atcctDECRWx0wH5crVCap61TO8ic/L0ONqqoJ XINMc/xYk2HwztdF8zCcYziyyIrC5bOXroSZsIv1Hw== X-Google-Smtp-Source: ABdhPJzcaCqgr11QYWDVxm5U1ZoBvRNmIRmzNiuhOOoSppgR9+tAOSm2GBC2GLF5xqnQtfuMLqlfIngrjsoQLKXg158= X-Received: by 2002:ac2:5624:: with SMTP id b4mr8940637lff.131.1596902308567; Sat, 08 Aug 2020 08:58:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 8 Aug 2020 10:58:17 -0500 Message-ID: To: tyson andre Cc: PHP Developers Mailing List Content-Type: multipart/alternative; boundary="000000000000d7f23005ac5fca3b" Subject: Re: [PHP-DEV] Putting the match expression in constant expressions in PHP 8.0 or 8.1 From: pollita@php.net (Sara Golemon) --000000000000d7f23005ac5fca3b Content-Type: text/plain; charset="UTF-8" On Fri, Aug 7, 2020 at 7:22 PM tyson andre wrote: > The match expression can be thought of as a much more concise/readable > equivalent to chained ternary operators. > I'm proposing allowing matches in constant expressions when all parts of > the match are constant expressions. > > That seems pretty reasonable. > 1. Should this target 8.0 or 8.1? I'm leaning towards 8.1 since the beta > is already out. > 8.1, the 8.0 ship has sailed. > 2. Are there objections to doing this? > Not from me, though I don't think I'd use it personally. > 3. Should/shouldn't php enforce that the default arm exists for match *in > constant expressions* > (constant expressions can already throw errors when evaluated for > various reasons, but UnhandledMatchError is new) > Such a construct would be compile-time evaluated, so not having a match should result in a compile error. Having a default should be considered best-practice (to avoid surprise compile failures), but I don't think it needs to be a hard-requirement. -Sara --000000000000d7f23005ac5fca3b--