Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117692 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 1659 invoked from network); 7 May 2022 19:34:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 May 2022 19:34:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EA816180339 for ; Sat, 7 May 2022 14:12:04 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f170.google.com (mail-yb1-f170.google.com [209.85.219.170]) (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, 7 May 2022 14:12:04 -0700 (PDT) Received: by mail-yb1-f170.google.com with SMTP id v59so18497057ybi.12 for ; Sat, 07 May 2022 14:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SLB/FmDNRpWlzRjQyQZslmv9sXeCsSgqde5azdWp7WQ=; b=UGTs8xnQWhuTKjOhqxbGa+0LNTgjCLgSa1scIjq9vDfub7t05Dri+/wsEJYUs528gl oFHbnGlz+Dlr8dHYkb67Y40HuO/uFnQ8/2cvIYv731J1UtN2PsBYzcW49vJAzalwEZid CBRi54plUqnTqnQ0B5koFVdMH+AtUDoIUxoW1q4ogSIXxggswl9hlIPamKpEDP6LQ13V TStEVAXebUWLZYGFor3XRs5FN4JCKidNTgpwND6siIIjfIeaDQDERByq5iaEasJmA9t9 PqOvi2n4F+L1vu+NepSuU2/G3EUJ7Nw1o280luOYHQ/1Sqc+MJctXjB8hIL0Vv+xlkaI DKQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SLB/FmDNRpWlzRjQyQZslmv9sXeCsSgqde5azdWp7WQ=; b=6eVevjiQSq42opylAfIVWkeD6DCsgpwXz/YQn1evw0pRkq++/qkViM5pYeGuB+1StF r1cW8f1dB2xYXs7vO6a8AgLRNdy8gjK5SJQYXjzLOjFBrvGuTy7F8Extx+LPuswmOcOi ETrt6bYRSfeDk4bFNBml+jLQK9QSezfmzBqVDrIBY+SWzU68ECB/iRTfLfaaDDakjTqZ Xl96QVa7gOJQgUcEaOaAP1Orre7gWpsr38XCk0GoPxu0TnwABinOfxpWPLi2lSeTBu1k 5LlSP20k4P7yFHHmYag/yzU/nizj+E5DCXEYGqaLbMcGgkVuC8caDT6NUxEkrX4+H+yl z0oA== X-Gm-Message-State: AOAM531Z8U2veY4jWtUoFJb3UOAZKhWKc88vrubT2Y/li+pI1vQqNn8M vkgvuqY20rzJRq9PsL/8vHuHEeeTcmZ3EMGakAp1xzit X-Google-Smtp-Source: ABdhPJxspuRFtXBdcyvBhMGnTRYUKQAq2lFundpUiLWuv0JUQzg4BLI+iG+fKq/bV5rkHsU0xjrzNUTSEWsCfQf6ebA= X-Received: by 2002:a05:6902:1002:b0:649:70c2:db58 with SMTP id w2-20020a056902100200b0064970c2db58mr7217905ybt.68.1651957923795; Sat, 07 May 2022 14:12:03 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 7 May 2022 14:11:54 -0700 Message-ID: To: Craig Francis Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000003b585c05de726db2" Subject: Re: [PHP-DEV] NULL Coercion Consistency From: jordan.ledoux@gmail.com (Jordan LeDoux) --0000000000003b585c05de726db2 Content-Type: text/plain; charset="UTF-8" On Sat, May 7, 2022 at 1:38 AM Craig Francis wrote: > > Not what I'm going for... but anyway, to get an idea of your position, do > you think the string '15' should be coerced to a number, or should it fatal > error as well? e.g. > > $my_number = round($request->get('my_number')); > > '15' is not an undefined value. If a program uses the paradigm that null represents the equivalent of something like `unset($var)`, then the program would not expect coercion to happen at all if a specific type is demanded, for the same reason that a C program wouldn't expect an out-of-range memory address to silently evaluate as an int 0. For programs that use this paradigm, the type system that PHP *already uses* which has a difference between `?int` and `int`, means that there is an explicit piece of code noting the exceptions to this rule about how null is treated. What exactly would be the purpose of `?int` if this RFC was passed? To pass the value as null instead of 0? That's it? What about `int|float`? Which one would it be coerced to? This pretty radically changes how typing itself would work in existing user programs. What I'm saying is that for such a radical BC break you need to provide some compelling justification, and I'm concerned from your replies in this thread and the content of the RFC that you don't actually understand the extent of a BC-break you're proposing. Jordan --0000000000003b585c05de726db2--