Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127301 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id B34E31A00BC for ; Wed, 7 May 2025 14:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1746629810; bh=L12XkUtyGP7+cNQQ9UuBiyhVYgmK5+OZDqbEvJ2iFaM=; h=Date:From:To:In-Reply-To:References:Subject:From; b=R0SitTVUb2n4KVr5lrFSbGMRlWS7I5oMwLk3+jQhSTlApHkApiymLgmAC7FeQ5+e/ z3WEMy8t3H3d43GqSnm5iQ+hhcq/wo+5oT1Jhnq4Z6AZ4CRon9q8TFhCfyytgAytRi 0+HyHuFxE9aKxZ4bQKMKewmb6VZ6GKkxb9d9TTB2fwerV6oPxupCnCNmkZEOES+K50 GUaEUObpfiLWgM7pGNKiYRSkixaDhm0MxZIdkF/mvP/hpUSdwEZ30uk3Sab7jUKIU3 67mmn5XmCTC3jHLLyfNlYYYpVkIJUflrNqJlFfbJV1pe50grvoqW3hSAPGDiUQRbol s0wMkLI9KX9mg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B88A018006D for ; Wed, 7 May 2025 14:56:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 7 May 2025 14:56:48 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.stl.internal (Postfix) with ESMTP id A0552254011D for ; Wed, 7 May 2025 10:59:01 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Wed, 07 May 2025 10:59:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm3; t=1746629941; x=1746716341; bh=ENArp929qxxNMgSHmil1w oBsRHybqZwkW46BQ/qIevY=; b=n2MRHaI9I4cTHnImD/rKgsJp9HohAiIdIA3e1 8wpNFBBxL52PM5gm+nkTzQtt6UnQkhl7PhMAF673Q2BI5cW/Q8BtgO/munV/xi+Y J2w6dFhefH7YRvT7gaGi9Brk4OKOs62CZUn/wJ71e0pcP+Sbcs3lcKB0i+n/BjyS N3kPDESZPXZMkhrvY9uPB1ZZ0kfV2Y2KQhgDWFmxthpl2fAvhxqmKgsZyj3B5Nq+ wWAUb1ouaLKDHLJke4Odlr2vccFaYPWlEcDQUzA1fxciCUNkbe8KA3FwT8rsQ0Bq r9RZP4QYs/u4yBGMxAAOOPB3q7w1FTGK8UI18fYvbGAk6jK/Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1746629941; x=1746716341; bh=E NArp929qxxNMgSHmil1woBsRHybqZwkW46BQ/qIevY=; b=vSiBeq+lRskcuA+R3 SEuJ+tWfPeLn+9HRUPzv/lCILm9h1La8LPk8iwleyCfqbzmM0kkq9qdK0qckzlPU WzLCB2nm+ldcydjTw+GTEO57P8atGIM/jfQ0k/Dp10IYJvrXY3vXHEQWOot8hfqK ZiHRIHsSyS/C33sQr0FP/gBidgC72R9rK8N2DflNlcTcPhqIwzPqbRDOXqFN1NwL 3txAxlyFraibBFstZYMMy9uhAeUDVtg4byyKxay+eF0q4HOU/RStFY+ogo4OClEr x5GFG4Tw8apRC2KfAwUBVBZKW1//QYCcOPVSkqfS0dRdqGYjikpadoDsKBG6Zafz BoCsg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvkeejudeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthejredtredt tdenucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrh hfihgvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpeetfeeileevtddttdeg ueffledulefhvefghffhgffhheehvdefheevuefhudevkeenucffohhmrghinhepghhith hhuhgsrdgtohhmpdhphhhpqdhmohguuhhlvghsrdhmugenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihsehgrghrfhhivghlughtvg gthhdrtghomhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghp thhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id F0021B0006A; Wed, 7 May 2025 10:59:00 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: T2a4bd2276428daf8 Date: Wed, 07 May 2025 09:57:22 -0500 To: "php internals" Message-ID: <4e0bc5b1-48af-4b4c-9d75-3d20245824f2@app.fastmail.com> In-Reply-To: References: <9cbbe803-5fd1-4011-b42e-033d4ede3fe9@app.fastmail.com> <15a33d20-47c1-443e-aafd-f39bd8f367c1@app.fastmail.com> Subject: Re: [PHP-DEV] Modules, again. Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Tue, May 6, 2025, at 1:33 AM, Michael Morris wrote: > Resetting and moving the proposal writeup to a github hosted markdown > file here: > https://github.com/michael-lloyd-morris/php-modules-rfc/blob/main/php-modules.md >> From your follow up statements, it seems that what you are proposing is not "modules" in any sense used in any language I am familiar with. Rather, you're proposing a symbol table hack to get around PHP's inability to load two symbols with the same name, and using module terminology to inaccurately describe it. (And thread terminology as well.) That is, it seems your intent is that I can import arbitrary code from an arbitrary package and shunt it off to a separate symbol table. But it's not clear if you intend for the package author to have to do anything to enable that. Your answers seem contradictory. >> >> For a concrete example, I'll offer my AttributeUtils library: https://github.com/Crell/AttributeUtils/tree/master/src >> >> It has a whole bunch of interfaces, plus a few classes. We'll focus on a subset of them for the moment. >> >> Analyzer.php (this is the main class someone uses) >> AttributeParser.php (this is an internal class used by Analyzer, you should never use it directly) >> FromReflectionClass.php (an interface that other libraries implement to trigger certain functionality in Analyzer) >> > > > In answer to your question - assuming the module file is at the root of > your src directory. > > module \Crell\AnalyzerModule; > > export [ > \Crell\Analyzer, > \Crell\FromReflectionClass > ]; > ?> > >> Say I want to modularize this library, under your proposal. What would I, as the library author, do exactly? Anything? How can I mark AttributeParser as internal-only and thou-shalt-not-use-if-you're-not-me? (That's the most common value of module systems, and the one most people in PHP seem to think of, from what I've seen.) >> >> That library is used extensively by Serde (another of my libraries). If I modularize AttributeUtils, then what changes does Serde need to make? > > On that end > > require_module ; > > $analyzer = new \Crell\AnalyzerModule::Analyzer(); > ?> > > If the autoloader gets updated to identify and properly load modules > (outside the scope of this RFC) the require_module statement can be > dropped. If a use statement is desired it looks like this > > use \Crell\AnalyzerModule::Analyzer; // This is legal for modules, not > for static classes. > > $analyzer = new Analyzer(); > ?> > > >> What would it get out of doing so? > > Nothing much - it just wouldn't be able to see as deeply into the > AttributeUtils code. So it's not really giving private symbols. It's not even blocking access to anything, since it can still just be included or autoloaded. What you're proposing is really just an optional loading facade (the real kind of facade) that lets you pull random symbols into a separate symbol table, accessed via separate syntax. (Either a class-like AnalyzerModule::Analyzer, or use-require.) Putting aside for the moment the question of whether that is a good idea or not, it is definitely not "modules" in any typical sense. I really don't think calling it "modules" is doing your proposal any favors, as it's just leading to confusion. What you're describing is a name-mangling facade, or symbol table facade, or something like that. (I don't know that there is a standard name.) I strongly recommend you recast your terminology around that, rather than "modules." That would remove a lot of confusion and allow people to review and respond to the idea you're actually proposing, now what they think a "module" should be. --Larry Garfield