Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124075 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 qa.php.net (Postfix) with ESMTPS id 89C0F1ADA78 for ; Sun, 30 Jun 2024 06:48:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719730197; bh=7c3wAIcx+qiYWJJ3W9FfgxVMgoGQCiiICbc6XQQUz1c=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=W/mPPMvZtcb7FD9U8lJ18yOX473+j11JvyZoDLlUPjk7x+8+s6LxZpA9IsnUWx3mH T7Ii0cfOVzygNfov7DCKL/LhENnJm31RLnl6nihSOrDf8vpSBSbGmFR3d/N61pv1Yl u3OLvtqGf9HN7BmANjEw2QlbvZBaRPi0GSydrWoW77BtLSyHHS3ueRn+Ekojrk9D0q 5DMzZr0Bco7THLW5LqSB/Py/CihtrHouxpdft4XW5nYVsahrXXoGdBsLsw12Y+z7Ui kqLoBl+M2oP4ZEqpqU8Y8V3IhgNmnWQ1EoLPr9+qV4G3ZA5BMOozBHewCkAS52sJ8F IzpsXQs4ooQMg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 46CA91801EB for ; Sun, 30 Jun 2024 06:49:55 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (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 ; Sun, 30 Jun 2024 06:49:53 +0000 (UTC) Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-70211abf4cbso128137a34.3 for ; Sat, 29 Jun 2024 23:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20230601.gappssmtp.com; s=20230601; t=1719730112; x=1720334912; darn=lists.php.net; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VpFDkGoygQ75wfqQBTJE9xhXcbnWqHCg+s3WrYfNepI=; b=TInY2+c/VSr3iVjlIBZphq0aaUzlPoV6GK+nmD4JBWWSynSlXVYLHIqzan+uIuyubH oYkMLgzh5NziY7GtT82eoGiXGBA22BG91jlkQ802zGMoh4BrDTqWNmAYsOKbDG/qVjkE KH1gzS8+MFDPNPa1rp/j/sJxmgcKrFT5xCyNH+bzoK//H6Um5L97xqQ+doRXvFwqwOTn ruD9Mx7bwkhW1cvMjF4QS6i1yZY+Zq1slPH42CJ6DOlRrZZ+A+bydYtoqZI0obgJZ3N9 u7URs82M3cg+VWTbSSMMFDHPpL3V0JOJzdRBD+SG24DHS+dUORHd++spB8yLvnrQb6Cf ANaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719730112; x=1720334912; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VpFDkGoygQ75wfqQBTJE9xhXcbnWqHCg+s3WrYfNepI=; b=N9k7/aid1o4u8cQfyQjm0olvWttvAYkSn70mpmzTStf5S69HnQZYItTcelw4BlVRAJ zqPP1/3oDo/6TX49zdVV98t1DatG+2w1yTcQTJl2IVUQyRs4Q2VqQdIui7ivzwYy2l4D hDQGwSokBb52sbQHUAPXLo7QSBCzaOzocu3n+K7rcBChP0mM5afdMBFAZ2bToNymyMuF lLYI1jyj+7eZvJPO23Dui+iPxTHHPyOQ4qfPGNL4FI5EkIk13qsOH0jqVGj6btNjespH TVsS6tQq9DD78Ama99YDCp8QkpSydCjAC17fWQ58cus1MagljzoGqU6hgzun4HZL24fi LsHA== X-Gm-Message-State: AOJu0YwYKLYppWFof7t3y3uvlT6XogI5WCKItg47dqx2yn/mmo6qqQRH n/4rohvcQRnrJ4s0b/aWOGZmnR9t9HTkGVNnscCgBZVncoAYcKbCCtwm3DgvSEpKqdr+xUi8B5H rW60= X-Google-Smtp-Source: AGHT+IHxbdm1DsGwcU35b3KyxVR/nNQmrI5OfEprl3Yi6KII9Rh0aAmzF31WOt4CfNzIB5AUI+Oczw== X-Received: by 2002:a9d:69c9:0:b0:700:ccfd:9350 with SMTP id 46e09a7af769-702075e40c3mr3184186a34.14.1719730112391; Sat, 29 Jun 2024 23:48:32 -0700 (PDT) Received: from smtpclient.apple (c-98-252-216-111.hsd1.ga.comcast.net. [98.252.216.111]) by smtp.gmail.com with ESMTPSA id 00721157ae682-64a99f528a9sm9242137b3.18.2024.06.29.23.48.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Jun 2024 23:48:31 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.8\)) Subject: Re: [PHP-DEV] [Initial Feedback] PHP User Modules - An Adaptation of ES6 from JavaScript In-Reply-To: Date: Sun, 30 Jun 2024 02:48:31 -0400 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <856F4F70-DC81-4098-82DD-5F6D47CDF3F0@newclarity.net> References: <1917CF7C-26D8-4DBE-B05C-5AA650AC6C9F@rwec.co.uk> <551cd5b0-1c00-4818-a9ca-97f6b7e8c3dc@app.fastmail.com> <39B496F8-062E-4848-9B3B-529BE8D3415A@newclarity.net> To: Michael Morris X-Mailer: Apple Mail (2.3696.120.41.1.8) From: mike@newclarity.net (Mike Schinkel) > On Jun 29, 2024, at 10:57 AM, Michael Morris = wrote: > On Sat, Jun 29, 2024 at 5:40=E2=80=AFAM Mike Schinkel = wrote: >> However, be aware that in a Go project repo you are likely to have = only one `go.mod` =E2=80=94 or multiple if you have numerous CLI apps = being generated =E2=80=94 whereas every directory with Go code is a = package (which I think is equivalent to what you are calling "module." > In my examples I have a local developed module being consumed by a = project (the index.php file). Trying to keep it simple in this early = sketch out. > =20 > So I think your use of them here is conflating the two concepts. One = is a project-wide concept and the other is a "package" concept. >=20 > I may well be. I'm looking for something that makes sense in PHP. = Namespaces, for good or ill, are a part of php, which is why the php.mod = in my example declares a namespace, not a package. > =20 > Also, it is problematic to have `php.mod` and `php.sum` because web = servers would serve them if not carefully configured hence why I went = with a leading dot, e.g. `.php.module` >=20 > This is a tree detail. Working on the forest overall right now. Not = that it's wrong, but leading dots to hide files is a .nix feature that = doesn't work on Windows (though applications ported from .nix to windows = often continue to honor the convention). > =20 > Aside from being familiar per Javascript, what is the argument to = requiring the import of specific symbols vs just a package import, e.g.: >=20 > import "./src/mymodule" >=20 > mymodule->twig->render('index', ['name' =3D> 'World']); >=20 > To me is seems to just add to boilerplate required. Note that having = `mymodule` everywhere you reference `twig` makes code a lot more = self-documenting, especially on line 999 of a PHP file. =F0=9F=99=82 >=20 > PHP's variable table and symbol table are entirely separate for = historical reasons. Plenty of people on this list can explain how and = why, but suffice to say namespace declarations have no effect on = variables, and variables declared outside functions go into the global = scope - which is a real trainwreck of a place in long lived = applications. Wordpress, for example, has a FRIGHTENING number of global = variables, and they aren't namespaced (they are prefixed, but that only = goes so far). >=20 > Modules have their own variable scope. They don't affect the global = scope at all and I don't think they should be able to import globals at = all with the global keyword, but that sort of thing can be discussed = later. They are also going to need their own symbol scope in case one = module needs to run an older version of a dependency it would otherwise = share with another module in the same project because there is a BC = break between the two dependencies. >=20 > That said, I wonder if incorporating versioning does not make the = scope of modules too big to complete? >=20 > In my experience it's best to get a roadmap in place - which is what = we're doing here - and THEN scope out the roadmap and determine what = pieces go in over multiple versions >=20 > I don't think it is wise to intertwine this concept of modules with = namespaces like that, but I am replied out for the night. :-) >=20 > I'm not sure we can completely abandon the concept of namespaces so in = this version of the proposal I incorporated them since, in the initial = ramble I ignored them. Where they land is as of yet an open question. After some private time spent documenting my thoughts on modules I = realized my thoughts have diverged from your proposal, so rather than = challenge any of your arguments I will just demure and work on my own = contribution.=20 I discovered the need for a small new feature that would generally be = incredibly useful but also could empower userland to create their own = form of modules, and that feature proposal will be much smaller in scope = compared to one for your concept of modules. It may or may not be = orthogonal to the discussion you are leading. -Mike