Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127356 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 4620D1A00BC for ; Wed, 14 May 2025 14:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1747233543; bh=eqZX4fIl2RM+jB4aPwQl6ZKfIF28ks5D105L1FOWVII=; h=Date:From:To:In-Reply-To:References:Subject:From; b=T1NkTMA4SBoEaFpCsN/YBds3sLyr2fHaLp1xCK8FIMtMP8+TucM18ep4Vgynfk793 V4JlTz4NJsCnhhugB+MYMNsOjpQmYKObxyEXW+L2QovuKZoc94mei9Z6+ErLjk09Zn 4CX049ZK8d7juDnL5+IV/Ff/PSVFuchkFaSM6hQRWVkxYFc3mBgHDhC9CGvlL/dGXc HceMRFTLRhCykyH6Im7f/KIt7Er1u4gaPKBbmIwMmlf7D0btX7pQpADjwqM00pf0Eh LMZ566d/AvDRsBuvionfhhmwnIqYiSCoXLarL752bBMZVk9qJ1kp/Gy+mi27yuzlO2 SCmJ1GbKTNOhw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 731021801D6 for ; Wed, 14 May 2025 14:39:02 +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.9 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,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 fout-b7-smtp.messagingengine.com (fout-b7-smtp.messagingengine.com [202.12.124.150]) (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, 14 May 2025 14:39:02 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 6C96411400D6 for ; Wed, 14 May 2025 10:41:12 -0400 (EDT) Received: from phl-imap-10 ([10.202.2.85]) by phl-compute-05.internal (MEProxy); Wed, 14 May 2025 10:41:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc: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=fm1; t=1747233672; x=1747320072; bh=28jsbitWAA VzrgyQLOMVm7+7RfPp+3f55rk/sm+Ve4c=; b=VLbsl1D0b3DsBKiFeTn4FjXv7Q 2dsK71hgcE8i47NeTSQQdv6UaC5H8y+bmxenflePGynvU7S5FQSVLd1O0FUVa9Og +t/kyr/mUfvw0NeOFmqEMvSrkyZqyhoZmHRUWnCWk7ratsmuzywzUwpUHTdbConx sJIz21/d+D7RNg+RogqWNwEH1CL9GHWxUyhLqmavbtL7WBIZqUX3UVHhxDkNnyJv CStFPMLAlrOnUoENESn28t91X/Nq0zKiqqq+CUZzPa8jHASWq2PWcy3HPhYi1xBp O1bOCmGzufWZIGojopQBUggXFMhKgOJVvwVI5u6MFORkKPGWYUDfvrvlHBmg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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= 1747233672; x=1747320072; bh=28jsbitWAAVzrgyQLOMVm7+7RfPp+3f55rk /sm+Ve4c=; b=IMAQZWKOXdZ9V/S3Xz//Gmh/qo0O9NpRwkPYqOn5+bgm1GT8UOQ yys7I48ublY7KCBpg84yBBk7psqOiZUVWk5Vywd0zeXHbp2Q0VlbbT4fBHEoYaFa 2g7IbgwGhq8m+1vRH3jqf+9Nco80rE2qa0tzf6mFcEDZlbmcyhA04HTSRyZnVg56 V1ll49pg2KyL8XgSzraVCIcpVOLaER1ONMi2uD3JhugfOnUifadqH0HSZf1wSqcY HCp6/rM00SGFdOs2lYxqSSIRc2TrB4tAi2GYt1fZkS9P82TbMTazzdi/LZ/sgNYl lm0CwH8yoLFHXp0i/wmfCjAVcjzR4DBDx8A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdeftdejvdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefogg ffhffvkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhs fdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtthgvrhhnpedtue ejtdethfeulefhtdelieduteelffdtudelheffgedtieehhfelieejgfevgeenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtth hlvggurdgtohguvghspdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdp rhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id C1FCD3C0068; Wed, 14 May 2025 10:41:11 -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: T018bd9ffc60205f7 Date: Wed, 14 May 2025 16:40:40 +0200 To: internals@lists.php.net Message-ID: In-Reply-To: References: <3ae9a6ea-f135-472b-b2bf-e6cd6ebad299@app.fastmail.com> Subject: Re: [PHP-DEV] Module or Class Visibility, Season 2 Content-Type: multipart/alternative; boundary=621add3e83134630864dd491bddac834 From: rob@bottled.codes ("Rob Landers") --621add3e83134630864dd491bddac834 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, May 14, 2025, at 15:24, Michael Morris wrote: >=20 >=20 > On Wed, May 14, 2025 at 4:08=E2=80=AFAM Rowan Tommins [IMSoP] wrote: >> __ >>=20 >> What Michael Morris is talking about is really a completely different= concept - it's more like "containers", in the sense of Docker, Kubernet= es, etc, where different sections of code can be isolated, and declare c= lasses with conflicting fully-qualified names. I don't think it's what m= ost applications and libraries would want "modules" to be; it's probably= best thought of as a completely separate feature. >>=20 >=20 > Well, it's what Go calls "modules". It's confusing because I was being= truthful, not snarky, when I said "Ask 10 programmers for the definitio= n of module and expect 12 answers." I'm self trained, so I expect to ge= t my terms wrong from time to time. But I know enough to identify proble= ms and needs and I've tried to be clear on that. >=20 > I'm currently reading up on Phar and seeing exactly how suited it woul= d be as a foundation for a module system. I've also been reading on how = go approaches things, but go has package management baked into the compi= ler - PHP outsources this to userland. I'm going to guess that's largely= because of lack of staff - PHP has no large backers (leeches like Faceb= ook that use it heavily and could back it yes, but not backers) and Go h= as Google. >=20 Hi Michael, Since it appears that nested classes probably won't pass by tomorrow (an= d thus no need to even touch short-syntax classes); I was going to focus= on modules next. As I mentioned in that thread, the two are very closel= y related on a technical level -- it would have only taken 2-3 lines of = changes to turn it into namespaces-as-modules and another 10 to turn it = into proper modules (minus syntax support). However, I would implement i= t very differently knowing what I know today and with this as a goal (vs= . nested classes). I have zero idea why people voted "no" and the people= who expressed their reasons didn't entirely make sense either. So, I su= spect it was just down to a poorly worded RFC and/or misunderstanding of= how it worked. I'll have to revisit it again later. Sorry for the vent; that's not what this thread is about. Modules. First of all, I'd be more than happy to help with the implement= ation if you're up for some collaboration. Personally, here are my requi= rements I was going into it with: 1. Impossible name collisions. If you want to name something Foo\Bar in= your module and I want to name something Foo\Bar in mine; we should be = free to do so. Implementing this is straightforward. 2. Simple. I don't want to rely on a package manager to create modules = or even use them. I really like the simplicity of "require_once" from ti= me to time, and I don't want to see that go away. I have some ideas here= , like `require_module my-module.php` 3. Easy to optimize. A module should be compiled as a complete unit so = opcache (or the engine itself) can make full use of the context. There a= re a lot of optimizations left on the table right now because the engine= dynamically compiles one file at a time. I haven't really even considered syntax too much; but I personally don't= want anything new -- or at least, too "out there." I want it to feel li= ke a natural extension to the language rather than something bolted on. I suspect there will need to be at least two new user-land elements to t= his: 1. a "module loader" that operates similar to the unified class loader = Gina proposed. 2. importing modules and aliasing them (as needed). Would you be interested in collaborating further? =E2=80=94 Rob --621add3e83134630864dd491bddac834 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Wed, May = 14, 2025, at 15:24, Michael Morris wrote:

<= br>
On Wed, May 14, 2025 at 4:08=E2=80=AFAM= Rowan Tommins [IMSoP] <imsop= .php@rwec.co.uk> wrote:


=
What Michael Morris is talking about is really a completely d= ifferent concept - it's more like "containers", in the sense of Doc= ker, Kubernetes, etc, where different sections of code can be isolated, = and declare classes with conflicting fully-qualified names. I don't thin= k it's what most applications and libraries would want "modules" to be; = it's probably best thought of as a completely separate feature.


Well, it's what Go ca= lls "modules". It's confusing because I was being truthful, not snarky, = when I said "Ask 10 programmers for the definition of module and expect = 12 answers."  I'm self trained, so I expect to get my terms wrong f= rom time to time. But I know enough to identify problems and needs and I= 've tried to be clear on that.

I'm currently re= ading up on Phar and seeing exactly how suited it would be as a foundati= on for a module system. I've also been reading on how go approaches thin= gs, but go has package management baked into the compiler - PHP outsourc= es this to userland. I'm going to guess that's largely because of lack o= f staff - PHP has no large backers (leeches like Facebook that use = it heavily and could back it yes, but not backers) and Go has Google.


Hi Michae= l,

Since it appears that nested classes probabl= y won't pass by tomorrow (and thus no need to even touch short-syntax cl= asses); I was going to focus on modules next. As I mentioned in that thr= ead, the two are very closely related on a technical level -- it would h= ave only taken 2-3 lines of changes to turn it into namespaces-as-module= s and another 10 to turn it into proper modules (minus syntax support). = However, I would implement it very differently knowing what I know today= and with this as a goal (vs. nested classes). I have zero idea why peop= le voted "no" and the people who expressed their reasons didn't entirely= make sense either. So, I suspect it was just down to a poorly worded RF= C and/or misunderstanding of how it worked. I'll have to revisit it agai= n later.

Sorry for the vent; that's not what th= is thread is about.

Modules. First of all, I'd = be more than happy to help with the implementation if you're up for some= collaboration. Personally, here are my requirements I was going into it= with:
  1. Impossible name collisions. If you want to name = something Foo\Bar in your module and I want to name something Foo\Bar in= mine; we should be free to do so. Implementing this is straightforward.=
  2. Simple. I don't want to rely on a package manager to create mod= ules or even use them. I really like the simplicity of "require_once" fr= om time to time, and I don't want to see that go away. I have some ideas= here, like `require_module my-module.php`
  3. Easy to optimize. A m= odule should be compiled as a complete unit so opcache (or the engine it= self) can make full use of the context. There are a lot of optimizations= left on the table right now because the engine dynamically compiles one= file at a time.
I haven't really even considered syntax t= oo much; but I personally don't want anything new -- or at least, too "o= ut there." I want it to feel like a natural extension to the language ra= ther than something bolted on.

I suspect there = will need to be at least two new user-land elements to this:
    a "module loader" that operates similar to the unified class loader Gi= na proposed.
  1. importing modules and aliasing them (as needed).
Would you be interested in collaborating further?
=
=E2=80=94 Rob
--621add3e83134630864dd491bddac834--