Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119477 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 39834 invoked from network); 7 Feb 2023 11:32:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Feb 2023 11:32:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C357E180340 for ; Tue, 7 Feb 2023 03:32:14 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, 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-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 7 Feb 2023 03:32:14 -0800 (PST) Received: by mail-wr1-f49.google.com with SMTP id i5so6063827wrc.0 for ; Tue, 07 Feb 2023 03:32:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=XbqQjMF1GgF5b9Osa91PHHtNEG+5VDcx6ukChHEwwS4=; b=m7drawArxyW1a/c0PL5h7aEgXKBRkWGo7vHDpOvw3tvtfdaVd3MwgDouNGh8UaDCTY GQBeZrhCwLG9kCFsr2FDA1HHtIYle8oREB6SCVKL7MbJz6X08wTIzXmfNYTum6FU1T9d sT+x+gulMe018EpzS94TFCHw5oPgGL+d/Im8+YPUx+QVINFtWKTM3k86IwAVb1JExqlJ qbGXXzfqt1h/c1EqFbzyPaG3S7hBGoi3e+LaKqdLkoEByD7zUDjYj5l+41b/lnnkxF1p KtIDF31l5tWQQrJQYigXLifNitotYGjwtsJJ03aRMyo9Gjxq8X6WZwwfzzjCxz1c3ltX TORw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XbqQjMF1GgF5b9Osa91PHHtNEG+5VDcx6ukChHEwwS4=; b=LrVsFlH/mCjIPuHMwoLpodVzJz+W3RVgdGOKFRmBnfx4SETs2TxqU4Uls5QGH47uJc ztRD3hetoFpIgEFii5uLSEiyU3TQtMh4nkfwRe3AusFY+LFl1Xs11dOn5GUdFpjZDLgC 3hmuTfSHa8zZJAQhJ+pUzqBWI9aDL9YQMQKYmZuGYfvKV1EX4qRWm4Mo92euxMaVLuAR +hpGe1EPlwMyURW3thYplNOQHZ01YFT3D254FrXWxgkY1DrAwnJT6AIJVwL1plXdOnqw R0nKWpnn58au3QF9km9NkOdSUV8D2Jlc520GoJXF51RxvFLorDj7tl0BsCputdrcxi22 zhSg== X-Gm-Message-State: AO0yUKVfbovRCje1syAQoqQemj8WLrZf8acZjac4xBCIWkp93+cIarVq TNBAQumR4Mw7HoAiQFDML0elIw00zUA= X-Google-Smtp-Source: AK7set8FBKGnmQpIPv81AskJAab+xqBD1VrZtyOT+495IyZvL4yi9adABRIDrHIx7Rz+2zIr4FNyAw== X-Received: by 2002:adf:e18e:0:b0:2c3:f070:911f with SMTP id az14-20020adfe18e000000b002c3f070911fmr2621846wrb.21.1675769532935; Tue, 07 Feb 2023 03:32:12 -0800 (PST) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id e23-20020a5d5957000000b002366e3f1497sm11056218wri.6.2023.02.07.03.32.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Feb 2023 03:32:12 -0800 (PST) Message-ID: <8c3fb742-4367-0e4a-b96e-142657ac902c@gmail.com> Date: Tue, 7 Feb 2023 11:32:11 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 To: internals@lists.php.net References: <18627e9c82d.1185ba82a2669697.6762525826203739336@wendelladriel.com> Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC Proposal - Types for Inline Variables From: rowan.collins@gmail.com (Rowan Tommins) On 06/02/2023 21:15, someniatko wrote: > Can you describe some use cases where this feature will be useful? I see > it's coming from statically typed / compiled languages like C++, but in > such languages compiler must know variable type in order to manage memory > properly. As PHP is an interpreted language, it doesn't have this problem. I'm not convinced the distinction between "compiled" and "interpreted" languages is actually meaningful for modern language implementations - PHP does have a compilation step, and even performs some of its correctness checks at that stage. Much more important is the distinction between "static typing" and "dynamic typing". The aim of a static typing system is to *prove*, in the mathematical sense, that the program is correct according to the type system of the language, without executing any of the code. The aim of a "dynamic typing" system is instead to *detect* problems in a program, while it is running, and to select operations overloaded based on the actual type of data. PHP itself currently only includes dynamic typing features - effectively, all the type keywords you add to the source code translate to run-time assertions that check the type of data at specific points. Mostly, that's currently at function boundaries (parameter and return type checking), though typed properties are more complex (especially when you access one by reference, and get a "typed reference"). One of the big implications of that is performance: adding checks in more places (e.g. on every assignment to a local variable), or more complex checks (e.g. checking every element of an array), means that the actual program runs slower. It may be possible to implement checks in a more efficient way, but it's not going to be a simple patch. That's why including an official static analyser is tempting, but it's not obvious where that would fit in the project and ecosystem (see the recent thread on that topic). Regards, -- Rowan Tommins [IMSoP]