Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108020 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 29425 invoked from network); 7 Jan 2020 03:20:22 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Jan 2020 03:20:22 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3584C1804D1 for ; Mon, 6 Jan 2020 17:25:24 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) (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 ; Mon, 6 Jan 2020 17:25:23 -0800 (PST) Received: by mail-yb1-f173.google.com with SMTP id x14so22942356ybr.4 for ; Mon, 06 Jan 2020 17:25:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=m1txpxZL8nMTvQGcm9gGRsG6Om+KpEN5yPzEG8R8m9c=; b=nKpqTr6oKHDklGz9qPt+xFIiZmFCK+Qu7Z3LIjt0LExm7C7R27lC+GaxOvZFFk1yl1 FuTilQ7Irb3CxJLlgF0Yqm/Qa+OHg1x0pBUzwzW/z6nFMPWKXhPkV07l2kX7rb2u3H3n /cIJsvwlrrpPTOi7yxcfRlGbphnGmljU0ImSbQv2OROqSxe9sSWGQGNB/s50nbCX1Gse pkAt7CQAxaW7DhFp1U67gKv4F+UvkCUn+nWXyXRHMww280xIg70A5zXzMsB/laHPuDAQ 0VlV7rfjAAiP9NlrDN2K4YDVnGx8CWnSZVi57yaGqfBKe+vym8mBhRFp73KtR5SuB4vu cVNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=m1txpxZL8nMTvQGcm9gGRsG6Om+KpEN5yPzEG8R8m9c=; b=f60OLJv9tca/Lu8IAUIW/6cjEY7GHk1LEy+nw/FBhMKXjILviJH6pHh1+peRQG0EIu bEnGjIwkZTMi9Uzy3DRBCEOouIEpoMvUvPsM3HYt+LF8LulQDy3zpmkPjTI/c79osV9E Si2Wxn8BZnV60/fu7uG5qBTs6Q+vxfh+KhOLJm4uODCMd/fUVROIK7q2Lx41Y5GMjlQt gzNCUhH0h7gIImTKvLym0XZ8SEOsAZOA97Y5hdPPj2aO0VsrLBpTzwlGf8U7IuFAXhxa fKPOi97D+nW9eh6CSG5oE0KoSnMrsEU5m7hmLjSy3hbBVMiaAQSpCGvmjqbYQKJRDfFB CKaA== X-Gm-Message-State: APjAAAWyfV1qfionm+zVMpCj8obWDq8YZIwB4dGKFxDQhvNsvp4D36Yn k4zJbmpfXIHXh1JRv0PmKfy+Zw== X-Google-Smtp-Source: APXvYqz+okUdyA59zX6t3zDuwHB+LRDJbUo6MeXfuqqOoymA3Q1WYFR/RfYn6AuB6arc7IadWEk1rQ== X-Received: by 2002:a25:ca10:: with SMTP id a16mr64814384ybg.280.1578360322268; Mon, 06 Jan 2020 17:25:22 -0800 (PST) Received: from [192.168.1.10] (c-24-131-44-78.hsd1.ga.comcast.net. [24.131.44.78]) by smtp.gmail.com with ESMTPSA id u136sm28720455ywf.101.2020.01.06.17.25.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jan 2020 17:25:21 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) In-Reply-To: Date: Mon, 6 Jan 2020 20:25:20 -0500 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <51656926-C86E-43EB-A973-8A2547E262E8@newclarity.net> References: <5e0d723f.1c69fb81.e2ae8.24e2SMTPIN_ADDED_MISSING@mx.google.com> <74F2DBFC-E63C-428C-A37F-2D0CEE15AD0F@newclarity.net> <8D8F3E7E-137E-459B-B13A-9C7940731243@newclarity.net> To: Rowan Tommins X-Mailer: Apple Mail (2.3445.104.11) Subject: Re: [PHP-DEV] Initializing constants once, with code? From: mike@newclarity.net (Mike Schinkel) > On Jan 6, 2020, at 5:52 PM, Rowan Tommins = wrote: >=20 > On 06/01/2020 21:01, Mike Schinkel wrote: >>> On Jan 6, 2020, at 5:56 AM, Robert Hickman = wrote: >>>=20 >>> Would it be worth expanding the ideas of programmatic constant >>> definition into a more general compile-time code execution approach? >> That would certainly be interesting. I do not know enough what is = possible there to opine. >>=20 >> It it were possible that might be the best of all worlds. >>=20 >> Anyone with experience in that area able to comment? >=20 > Isn't that the same as pre-processors, which elicited this response = when I mentioned them before: As I said it my most recent other reply I said I view pre-processors as = text substitution. But you might have meant something different than = text substitution? What I think Robert was referring to =E2=80=94 at least to me =E2=80=94 = was a form of pre-loading or recompiling into some form that could be = referenced by the normal code, not an approach that would generate a new = .PHP file. Something that can be linked via symbols at runtime.=20 Maybe something similar to preloading in PHP 7.4, but accessible by the = developer like .htacess is accessible to the developer, vs. just = accessible to the system administrator: = https://stitcher.io/blog/preloading-in-php-74 But I don't want to fixate on my definitions; whatever we call them is = fine as long as we both understand what we are talking about. > Parse the code to an AST, allowing function calls with literal = arguments wherever a literal value would normally be allowed. Find all = function calls to something in the MACRO namespace, evaluate them, and = substitute the result into the AST. Then write the modified AST to a new = PHP file, and deploy that to your server. It is the writing of the new PHP file that I think would be a = problematic. Again, from my other reply, such approaches are not = composible and that is my objection to them. -Mike P.S. Please tell me you are not the guy who wrote Pre from = preprocess.io, are you? :-o=