Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119473 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92254 invoked from network); 6 Feb 2023 21:15:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Feb 2023 21:15:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BC14C180504 for ; Mon, 6 Feb 2023 13:15:43 -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=-0.7 required=5.0 tests=BAYES_05,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-vk1-f173.google.com (mail-vk1-f173.google.com [209.85.221.173]) (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 ; Mon, 6 Feb 2023 13:15:43 -0800 (PST) Received: by mail-vk1-f173.google.com with SMTP id v5so6806479vkc.10 for ; Mon, 06 Feb 2023 13:15:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=JWMKoZRBnPsKRYM9fj+LgXkt5jQl89yZjFex4ppbZiA=; b=JCqq8vZ5CtqVFrdUTv6usuCCumnPXTvDJhpHdGfQI20K0ifdK9eWo/qFkps/V8h6f0 ojhIlyVUM3IW2Q1SRG27RqCG3uAShEB4zhpsTpZXf9QBo8uoh6pQCRkWbOC2AmmpQwPN P+LYH8wZwmqxR47lCf2nCoefXJEg2nuyKKpEJXsPin3oRse9MPn6T+9cFBkjf8KUgLas GHHFA2NKFymfLPH/JbfEgfTz9Lpgct1QbmTGTZr3zGerLzDWjeXADr80oIgSf4izKoDk oiOJuhQDNKjPENPdewTtzQQ9rlpXdBuiuq3B55EWXDEe30YaFcvmF8SzCt+Me4ig/Ste cXtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JWMKoZRBnPsKRYM9fj+LgXkt5jQl89yZjFex4ppbZiA=; b=IwYVTsduJ2m5aXhT6UixQcw1okMcBGOksivVtVb/FBCU6baocHqUarFRsWpSfzBreR K8/gqHVpqj29vL/AxNX/VthOVOnyWLA3f92VhF8LAzt+HOOA/pS7iIUkEkwMGWf+DzTw nbbbsmKNoNgXNqUpPvPj+d8nQusvXO0fe5dlB5aPhTUspfNjsMC9qAB7vHdbBfHv37v3 i1NTYciiGR5i/xtOCX9CpGi/PSeVaDEKgwSIE7+o+J91qGt+SfQ3XEQZV0wCT126pIJv tWOuyjcRx8IrT9Env3VT40/bEDwSfjp5mwkNXZmOPyDk90PPTJ+5Hv9XQb7JUl2dBXMA fO8A== X-Gm-Message-State: AO0yUKXadLm8mi8FlChjeZLTpkjNGC9z2DTE+XZOKtKm4CRW51ICa/sS GVN86uJ7mx6RYUU5g+bMeHshLVOR9B5rtx5thOA= X-Google-Smtp-Source: AK7set9GukeskhbWtmRaDuQmnV6JQIaRCTbDqwB9Y2AOKN1CPN4+cHYnQ0YMiYfenv/K8ipL/hn4dh7p1jdg4PKE+CQ= X-Received: by 2002:a1f:3016:0:b0:3d5:911f:daed with SMTP id w22-20020a1f3016000000b003d5911fdaedmr6045vkw.39.1675718142363; Mon, 06 Feb 2023 13:15:42 -0800 (PST) MIME-Version: 1.0 References: <18627e9c82d.1185ba82a2669697.6762525826203739336@wendelladriel.com> In-Reply-To: <18627e9c82d.1185ba82a2669697.6762525826203739336@wendelladriel.com> Date: Mon, 6 Feb 2023 23:15:31 +0200 Message-ID: To: Wendell Adriel Cc: internals Content-Type: multipart/alternative; boundary="0000000000009e8f7205f40e8849" Subject: Re: [PHP-DEV] RFC Proposal - Types for Inline Variables From: someniatko@gmail.com (someniatko) --0000000000009e8f7205f40e8849 Content-Type: text/plain; charset="UTF-8" Hi there, I am not a core PHP language developer, just a regular PHP programmer, and cannot speak for the whole community, so I'll just share my opinion. I believe a new language feature suggestion should contain not only its description, but also motivation: i.e. what are we trying to achieve with it. Will the development experience be worse without it, or maybe it disallows some sneaky bugs to appear in your code, or maybe it acts as a native documentation for your code etc. Personally it's hard for me to see what kind of improvement will restricting a type of a variable bring. It may prevent repurposing the variable with the same name for a different use somewhere down the function, which can lead to bugs if a function is large enough. However, for such cases I think better idea would be to introduce `const` variables like in JavaScript - which can only be set once and cannot be reassigned later. This way you'll also guarantee the type of the variable will be preserved. > We can add types in a lot of places, but we still don't have a way to add types to inline variables. > int $value = 10; > $value = 'foo'; // TypeError 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. Regards, Illia / someniatko --0000000000009e8f7205f40e8849--