Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108043 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 97491 invoked from network); 9 Jan 2020 11:33:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Jan 2020 11:33:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7C9791804A8 for ; Thu, 9 Jan 2020 01:38:39 -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,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) (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 ; Thu, 9 Jan 2020 01:38:38 -0800 (PST) Received: by mail-io1-f50.google.com with SMTP id z8so6428447ioh.0 for ; Thu, 09 Jan 2020 01:38:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=KXbVM4VQfBOaYc705Bt9n4cUQxrCXDHG72ooX61HEn0=; b=Z16SLDiyw+NIIKlRNaw4MyoRcd8ZH00vyzRs9OuZ/c76yTXyUj5xbJj8kbz1CfMykr S/ZQpa+JY+q3nfdnEh5ZtLK6ErMlJjuTukRWTV4xn+GQqYY5HEphI+zGYis3/gCP8ATE rIJ2eOTCIgiHiabEl3O+zK+z9P70/9XjJR7geo/G3vyjHK2oTKlt1Aay9nRoLio/bmRQ 5XbO95f8Z0Gt2c07nks8IvyVozMU/spLORObock72eeN6vOXteCmdt6yx4BLFSnZgf2l 5Iap4fzcGAnFAxsPKLYaPGURB1CC+96KsFlW4JSzQmCDSMjK9uNmZf/Z6EcAgsKud0eT Hpqw== 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; bh=KXbVM4VQfBOaYc705Bt9n4cUQxrCXDHG72ooX61HEn0=; b=nWZNeYdvGJgys/sjI7C1pGhKl4pAhoocrMPlR+KBDVbZGPmJB/PlQqCx/d3CFi9Qpv gPZDL/7FxfASyvhWWCh0RMssgqGQofwBHpA3Ts1ECf75JGImWKWOzpAs1HB3e3894I1N xm5NWTN5+hO4FshKFGrDWch9W1fEFxi4TpzSUM33u042reNBsj4r6J6Djr+GyyhWd2vs zOWd1I4m7qhFL5ckX4XWDYD+52klV/+39WMg8U3oJArpXI7NO1vE1xIRZKUZnHLX05JU yHlFFsyXfyj44o7fS7tuMIyNxmYVYhrO1HHRKNeXI4BvdttxrnwrkaREmwSWPhjK9ofy 6NXA== X-Gm-Message-State: APjAAAV81RZFVzGHVa4c6Aw2JhNIxqUmQe5jcdU2Abo/GlJByL137VAj /Al19a0HoEyr1d/x9VTJZymmX/U8dadYZenOUOm7t2/T X-Google-Smtp-Source: APXvYqxYv7acMWtc/lyhJl3AstfRx41mcGDD9+jkam+ElNQw4bD8nmTE9R8WFMmnNTu7Sb63r2L6Wi9dEQH0nui/Lv0= X-Received: by 2002:a5e:8612:: with SMTP id z18mr7179231ioj.206.1578562715087; Thu, 09 Jan 2020 01:38:35 -0800 (PST) MIME-Version: 1.0 References: <5e0d723f.1c69fb81.e2ae8.24e2SMTPIN_ADDED_MISSING@mx.google.com> <74F2DBFC-E63C-428C-A37F-2D0CEE15AD0F@newclarity.net> <53556dfb-44ce-f902-204c-9a7da9484a61@gmail.com> <65567C7C-CF0F-4562-8943-F1F302134B07@newclarity.net> <6f20bda1-eff6-631d-915f-d6bb149ee666@gmail.com> <93BA4B49-9D9A-4A41-83B3-8EC2564A70BF@newclarity.net> In-Reply-To: Date: Thu, 9 Jan 2020 09:38:23 +0000 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="000000000000e3788f059bb1c520" Subject: Re: [PHP-DEV] Initializing constants once, with code? From: rowan.collins@gmail.com (Rowan Tommins) --000000000000e3788f059bb1c520 Content-Type: text/plain; charset="UTF-8" On Wed, 8 Jan 2020 at 20:28, Mike Schinkel wrote: > > On Jan 8, 2020, at 5:48 AM, Rowan Tommins > wrote: > > > > I think immutable variables very much address the use cases you're trying > > to address, except for the additional requirement about which syntax > access > > should use. > > In the USA we have a saying: "Besides that Mrs. Lincoln, how was the play?" > Sorry, I don't see it that way. To my mind, the universal use case here is "initialise some value once and then access it from the program"; the syntax is secondary to that. Evidently, you see those priorities differently; I don't think we're ever going to agree on that. > > That's a really significant difference, because it > > means that they inherit all the behaviours and syntax of variables, which > > PHP's constants currently do not. > > Sorry, but this just feels to me you are arguing the aspects that support > your argument that PHP constants can't change, but dismissing the aspects > that do not support said arguments. > What aspects am I dismissing? I absolutely agree that an equivalent to Java's final variables would implement your use case - if you were willing to relax your syntax constraint. But your proposal is not to have immutable variables, as you've said yourself. > There is no reason this would _have_ to support objects. The use-case I am > bring up in my experience in ~90% string, ~10% numbers. > See my my earlier comment about implementation - I'm not sure how we'd define valid values so that they definitely couldn't be mutable. You could restrict to just scalars, but that would then be a tighter restriction than actual constants - "const A = [1,2,3];" is valid right now, so preventing that being set dynamically would feel odd. > I was suggesting the ability to run some code that would only run once > until the server is restarted or manually flushed in code rather than every > page load. > Perhaps I'm using the wrong terminology, but I think we're talking about the same thing: something that runs before the main program, which takes certain parts of the code, interprets them in some way, and combines them with the rest of the program. So: an interpreter that runs during preloading, which takes special blocks of code, runs them as PHP, and then combines the results into the AST/OpCode representation of the program. I stand by my comment that this has *some* of the same problems as a separate "build" script, such as the need to be configured correctly, the difficulty of debugging errors in this special code, and the need to invoke the extra processing manually for things like command-line scripts. Regards, -- Rowan Tommins [IMSoP] --000000000000e3788f059bb1c520--