Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127294 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 0CFB21A00BC for ; Tue, 6 May 2025 06:33:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1746513099; bh=/94snXX9Fom36Tk57Eb+4/mPGWIyg4zOwSRXBumLMZE=; h=References:In-Reply-To:From:Date:Subject:To:From; b=l9dWJhjMuEF8Zz8bnq6yibGBnQJ5Ld5cvP1FAoeC/CVb9rybC4T+H5FRZ1VfmmpgY 00OjM6hSVGmFrhaC7LOL1WrXuCPBgJpqLy3zdaPstZTIp325V/DBDcEz1BxNEqWt4R 45JgwD2LQoLq4JYI7tudVGbmte9iX/nifiDwbHcDJe1v/4K+pw2SU9l+Olm4N2tqnO L1aUJZlPG1rAYweBGMep/lt+xlRLyQ5XOu3mIOxxNKM5mATr3SdDA0hdpVoZikX7rW Ld9P9ucAw/YIkU6D/OMRQUXTuy+1vKRHjGLdYSa0+dz1Cu0SjUF++hQOLaw71Rcnl5 eLp+w6Gkwv8Xg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7564818004F for ; Tue, 6 May 2025 06:31:38 +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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS 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 mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (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 ; Tue, 6 May 2025 06:31:38 +0000 (UTC) Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-6f53c54df75so2394106d6.3 for ; Mon, 05 May 2025 23:33:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1746513231; x=1747118031; darn=lists.php.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=ygUHKNaYh2aVgyBhQzvJ46R4Y8CTBWlrq5x2/8GM8xM=; b=EjOGxevmyxvNk7bEzbRtqWAvDo+hMinAzUbz+z997jqBCx/FJ0bJUBza9xZJMlN8Qv 2iBQqE4xgP3LR4zgxhUbnecPcHIDPl5XomorJS9YXWjd14NzGWvivEvdtjBSSabMVyIo OKmqmo3i2N3otGM/y+yGTP5aMmsg/SIcNTKEYBWekgrbRqZkfrHt7sQBFkxCHfVWJi5f DYk1GeTtsUIgbEk4lYty94dVEUuBXyx83565R7qe0YkUrtc/4eaHXvVYA/HvekqIgMiz NJwPD9f+Rhpx6Q2vG3V3qNyROyB2EsfATIt+GY7CzgaL8InmJpjgFaowlJ7GBBvGnIqm 1Eiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746513231; x=1747118031; h=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=ygUHKNaYh2aVgyBhQzvJ46R4Y8CTBWlrq5x2/8GM8xM=; b=LGBpRWwTzxbR1ED6EOtccWeohqV3H8xEvjiF3QRAKqXKDkYnsX3tU7Mwz2kVwKLwtD fJI8m3L9htnTwXohU97EcqOEzHMIBNSUrQL6UjlLibvWEKTZUJdoUpD03QEtyMU91j58 pRBH4TXJwT21FPai+x0i5TxXBCkwiIPfSHQ7BHNy+jx5/ocuRgNPBYqcX9kNIxraYjbx JfkGYs+jqLNH2DvUVol4wmcySgXCGn7ynGPx94vjEeEurcM5FCWaxlntUUezQrnP6iqe mEwS13tVoQR9Y+ZB8B6OF6E/hvlnAhYNxTur6mn2TuQsZeR/OvOXxZsq16xk+gvPdkxE GtAw== X-Gm-Message-State: AOJu0Ywb/o4AuMHF5G+r56qc6LrSoSpWj0hsyyLObuiSVLHvncdQHksm gwN2XZO5KxCYGhceQXehyrvpKvf16EGBfUJzKSMplwtlDp7N/axph0YC78010hFOtIOQXcl48rI GhVJnNbcINopCSoPJF41LMZ9DEUB1gXJJ X-Gm-Gg: ASbGncvsa4F4JBMqADplVT6kr+Et/i3nkAPaIxYuqwCpY1e1rymQKws1TRhGKt18jOV CxHQTbXH0y8L7Xsh+mLtDIrGqb84u2yA7spgJlxa34Ddjrqi182WoJmFUsTFZJJOI3O3g2ey4Y5 mxzSM5sCpOl3qGbQykh9RfWkbsmix+sV667ttukaqWCyVFlq7BYIcBj3EJWv9cCN8= X-Google-Smtp-Source: AGHT+IHwZpVr4nzZgw5LiA9fuZTvb655t0ceRaHpsR3+H6/3GSbsM760RqepiQB256PY4G7G4DcFDuTBWNcV2bXAtZA= X-Received: by 2002:a05:6214:dc4:b0:6e4:2dcb:33c8 with SMTP id 6a1803df08f44-6f53541757dmr30847866d6.29.1746513231626; Mon, 05 May 2025 23:33:51 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <9cbbe803-5fd1-4011-b42e-033d4ede3fe9@app.fastmail.com> <15a33d20-47c1-443e-aafd-f39bd8f367c1@app.fastmail.com> In-Reply-To: Date: Tue, 6 May 2025 02:33:41 -0400 X-Gm-Features: ATxdqUFoeJu7-_93bwrykPjK53m_4X4zqZqACuQg64KULeFZ6LmxMvtUEAw6MkA Message-ID: Subject: Re: [PHP-DEV] Modules, again. To: PHP internals Content-Type: multipart/alternative; boundary="000000000000c44856063471cce0" From: tendoaki@gmail.com (Michael Morris) --000000000000c44856063471cce0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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-modul= es.md On Mon, May 5, 2025 at 12:44=E2=80=AFAM Larry Garfield wrote: > > > So before you get indignant and call me a liar ("You're 4 for 4 on > falsehoods"), perhaps consider how someone you know is "more intelligent" > than this can come away from your post understanding it so utterly > differently than what you intended. > I'm sorry for doing that. > > 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 inabilit= y > 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. > 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 ; $analyzer =3D 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 > What would it get out of doing so? > Nothing much - it just wouldn't be able to see as deeply into the AttributeUtils code. --000000000000c44856063471cce0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Resetting and moving the proposal wr= iteup to a github hosted markdown file here:=C2=A0https://github.com/michael-lloyd-morris/php-modules-rfc/blob/ma= in/php-modules.md

On Mon, May 5, = 2025 at 12:44=E2=80=AFAM Larry Garfield <larry@garfieldtech.com> wrote:


So before you get indignant and call me a liar ("You're 4 for 4 on= falsehoods"), perhaps consider how someone you know is "more int= elligent" than this can come away from your post understanding it so u= tterly differently than what you intended.

<= div>I'm sorry for doing that.
=C2=A0

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.= =C2=A0 Rather, you're proposing a symbol table hack to get around PHP&#= 39;s inability to load two symbols with the same name, and using module ter= minology to inaccurately describe it.=C2=A0 (And thread terminology as well= .)=C2=A0 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.=C2= =A0 But it's not clear if you intend for the package author to have to = do anything to enable that.=C2=A0 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.=C2=A0 We'll foc= us 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 tri= gger certain functionality in Analyzer)



In answer to your = question - assuming the module file is at the root of your src directory.

<?php=C2=A0
module \Crell\AnalyzerModu= le;

export [
=C2=A0 \Crell\Analyzer,
=C2=A0 \Crell\FromReflectionClass
];
?>
=
=C2=A0
Say I want to modularize this library, under your proposal.=C2=A0 What woul= d I, as the library author, do exactly?=C2=A0 Anything?=C2=A0 How can I mar= k AttributeParser as internal-only and thou-shalt-not-use-if-you're-not= -me?=C2=A0 (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).=C2=A0 = If I modularize AttributeUtils, then what changes does Serde need to make?= =C2=A0

On that end

<?php
require_module <path_to_Crell\AnalyzerModule&g= t;;

$analyzer =3D new \Crell\AnalyzerModule::Analy= zer();
?>

If the autoloader gets upda= ted to identify and properly load modules (outside the scope of this RFC) t= he require_module statement can be dropped.=C2=A0 If a use statement is des= ired it looks like this

<?php
use \Cr= ell\AnalyzerModule::Analyzer;=C2=A0 // This is legal for modules, not for s= tatic classes.

$analyzer =3D new Analyzer();
=
?>

=C2=A0
What would it get out of doing so?

Nothing much - it just wouldn't be able to see= as deeply into the AttributeUtils code.

--000000000000c44856063471cce0--