Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119921 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 89568 invoked from network); 11 Apr 2023 14:15:13 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Apr 2023 14:15:13 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D39E018054E for ; Tue, 11 Apr 2023 07:15:12 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 11 Apr 2023 07:15:09 -0700 (PDT) Received: by mail-wm1-f41.google.com with SMTP id j1-20020a05600c1c0100b003f04da00d07so849432wms.1 for ; Tue, 11 Apr 2023 07:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681222508; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=n9OB9TIb2eXztkzH/IJ9t7CDBmJxTgzJmPA/NKpcqUg=; b=CJ9D4/u7wLMG+gI5IO0920vaL3DyVQYJ+xP2aUPZsgBVRVYrQ6sYBabGNPLOVGEbB0 bo1pwDioW/rLtryPjtajBOcg5DRqSqAayeq3kd4S2eGOeDV8r1hECMcNgWcuP+I+QpY1 MiPw8ylPd6GXO7Lddg/SmwK7rMrDSYkpAnnRDlnH4XX4CpsQDbIao9O1tIr1CPyETz2a zfR1ahzdz7XJOOnA8N9mZDigg098QSwoO8V5G55mAko3Bcz0sj4UMwOFljsMTC7RdcCY BnRujv2+GtU9DDYZZXwoX0OnsxYImkBpsVB8UH6rjUvINtHufD4cO5wTC03YeN2PQZib vubg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681222508; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=n9OB9TIb2eXztkzH/IJ9t7CDBmJxTgzJmPA/NKpcqUg=; b=AMlYvT+BijVKWYintTOORfJhAVETmOivrFAx+HJwHhHg1jtiYhfWdlBO9v7SbHe/L0 /YLgfQiQhZqqCg0zk8Tm9Ezo+52QrWWWWSl0GtVk9JbERczz2km4Y0csRPeabiQPz/dw JlTM38cjQ5jzuQE9udC7o/y4OgBQv095K14ZRSiLWZuRlPPxXM2OJqjk80l7/8svf7kh CLNwUYvfoRkTm/vxm9bPPAGBvkoUBZezenR4SWM8WbnWoJ0lYO6ErDunx09+txgpxMba ePZK7WRcCgljmHi0jn5HDm8Xne6XYyY1wilKh+fHLst7DZGmkjHyorR/oIrO5teqtGFv 7FcQ== X-Gm-Message-State: AAQBX9cJvbhMar7KfMoMv74nRKd7/a8vmotGB8yQMLod1CWA4e2Sb3zA welmHLlScdM2shIvfnh80wqXLfhbnpXE1A== X-Google-Smtp-Source: AKy350YAyu7DkF4YjpeMBe/EOwp9UEwQZh9JDNpYY5pNDVPSAKXPF7Ebipa0bMujvo2LWN3yZDvQGA== X-Received: by 2002:a7b:c013:0:b0:3f0:46d4:b391 with SMTP id c19-20020a7bc013000000b003f046d4b391mr10376755wmb.6.1681222507944; Tue, 11 Apr 2023 07:15:07 -0700 (PDT) Received: from [192.168.0.240] (cpc88095-dund15-2-0-cust190.16-4.cable.virginm.net. [92.238.249.191]) by smtp.gmail.com with ESMTPSA id 13-20020a05600c230d00b003ed2384566fsm17094886wmo.21.2023.04.11.07.15.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Apr 2023 07:15:07 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------u14ZwrJLCCghshKh6DNGFYFk" Message-ID: Date: Tue, 11 Apr 2023 15:15:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US To: internals@lists.php.net References: In-Reply-To: Subject: Re: [PHP-DEV] PHP Modules From: jannesblm@gmail.com (Jannes Blume) --------------u14ZwrJLCCghshKh6DNGFYFk Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit I’d like to give my two cents on this as I’m currently exploring “dependency hell" as part of my dissertation, including a PoC implementation of a first-class module system for PHP. The hardest part was probably to find the least invasive way of limiting the lexical scope of global declarations like classes, free-standing functions and constants, similar to what Sara has described. I’ve ultimately decided to go with a “module.php” (manifest) file, that hosts an “export” array of said symbols that should be available to dependents. The file defines the boundaries of a “module” and all files loaded from within its directory tree will be treated according to the scoping rules defined in the manifest. While all of this is certainly possible, I can see a lot more problems, even with a more sophisticated implementation that is supposed to be adapted by the sheer amount of Composer packages to become useful for the community. PHP developers, rightfully, make the assumption that a definition will only exist once in the current execution context, as implied by namespaces and the convention of having one prefix for a Composer package (I’m aware that we’ve had some versioning in Namespace paths previously). > Say the mb module gets some bc breaks. We can put them into a new module so > that the behavior is once again opt in. The strongest way to do this is to > make composer a 1st class part of the language and let it specify the > version of the module that is loaded. If we’re introducing a possibility to have two or more versions of a function, class, constant, …, how can we make sure they do not clash across module boundaries? Is this the responsibility of the author when defining the public API? I think JavaScript thrives with its module system because it’s dynamically typed and I’d argue, that because of this, developers can get away with most minor inconsistencies in behaviour between versions. How would we combine this with strict types in PHP, that become more prevalent with each release? I’m a supporter of the idea in general but would agree with my predecessors, that it might not be viable right now due to the scale of this. However, I am curious to hear more thoughts on this. Jannes B --------------u14ZwrJLCCghshKh6DNGFYFk--