Re: Modules, again.

From: Date: Sun, 04 May 2025 21:37:23 +0000
Subject: Re: Modules, again.
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Sun, May 4, 2025, at 4:25 PM, Michael Morris wrote:
> On Sun, May 4, 2025 at 5:19 PM Larry Garfield <[email protected]> wrote:
>> On Sun, May 4, 2025, at 2:34 AM, Michael Morris wrote:
>> > It's been 9 months. Been researching, working on other projects, 
>> > mulling over 
>> > points raised the last time I brought this up. And at the moment I 
>> > don't think 
>> > PHP 8.5 is in its final weeks so this isn't a distraction for that.  
>> > The 
>> > previous discussion got seriously, seriously derailed and I got lost 
>> > even though 
>> > I started it. I'm not going to ask anyone to dig into the archives, 
>> > let's just 
>> > start afresh.
>> 
>> This proposal requires:
>> 
>> 1. Every module author to change their coding structure
>> 2. Every consumer of a package to change their coding structure
>> 3. Devs to abandon "it just works" autoloading and explicitly import packages.
>> 4. Abandoning 16 years of PSR-0/4 file convention in favor of "module = file",
>> which will almost certainly result in multi-thousand-line files even for clean, well-factored code.
>
> You're 4 for 4 on falsehoods. Care to actually read what I wrote 
> because I know you're more intelligent and better than this and very 
> disappointed. 

> PHP Code -----------------------------------------------------------------------
>
> namespace MyModule;
>
> yield function sum(a, b) { return a + b; }
>
> --------------------------------------------------------------------------------

Every module author changes their code.  (Which is reasonable.)

> PHP Code -----------------------------------------------------------------------
>
> use require 'mymodule.php';
>
> echo MyModule::sum(3, 4);
> --------------------------------------------------------------------------------

Every caller changes their code, to use use require and to use the pseudo-class syntax
to call the function.

> PHP Code -----------------------------------------------------------------------
>
> use sum require 'mymodule.php';
>
> echo sum(3, 4); // 7
> --------------------------------------------------------------------------------

Removes the pseudo-class syntax, but still has the "use sum require..." change for the
consumer.

As described, the implication is that the millions of existing

use Some\Class\Here;

lines in code in the wild will... not work if the Some\Class package becomes a module?  I think
that's what's implied, but it's not clear.  If that triggers autoloading, how does
the autoloader know how to find it?  It needs to know the module name, which as described is the
file name of the module, not the class.  

Since the module name is the file name, that means if a module has 50 internal classes, it must be
in the same file.  Hence, giant files.

If those reads of your post are inaccurate, then please show with examples how they are inaccurate,
because that is how I understood your proposal text at face value.

--Larry Garfield


Thread (21 messages)

« previous php.internals (#127286) next »