Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121491 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 5680 invoked from network); 28 Oct 2023 13:22:20 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Oct 2023 13:22:20 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 24D231804A7 for ; Sat, 28 Oct 2023 06:22:20 -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, 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-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 ; Sat, 28 Oct 2023 06:22:19 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-507c8316abcso3947680e87.1 for ; Sat, 28 Oct 2023 06:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698499338; x=1699104138; darn=lists.php.net; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=4q7t3B7l+c25VLshGLIvd7SD1/zSlCurvKL4pkbJiJA=; b=AG88XCv8nEaGrD+hq7bRFi/i1muQMCOcJAGEOOEPzr7Y/yVBhmSF5/5k1tob4c3B30 mRn9yPSheg9yuzrjk4F+VHDAibXawRqP8r+VScuQC7FbWzk4uAeiDGtAngLP1FG/XWWJ EegB1OQzQvvqf8FPu+Rmqa+TlTAIG2w/ydejpppKTMYMJpAOCDhSyczMkjI5pYZGC8XL ctQJE/rRKV2qod5yDtfnhOcHUuQU6ffJ7grGefBp+DzPdtBFESuD7kXTUY30CAAY1cCV 9FEMe/TWYs5z+z6CG8Yx8gCSAP1icDhTzzzOT+FJgpwWzIHFONi5bKhq4rQB/8PxbRiM 24rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698499338; x=1699104138; h=content-transfer-encoding:mime-version:message-id:references :in-reply-to:user-agent:subject:to:from:date:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=4q7t3B7l+c25VLshGLIvd7SD1/zSlCurvKL4pkbJiJA=; b=IKzz6cbM/lG9VE5bNciHblHQluE3A1ex5jtJF1+oFP8bgFnRZqSGDZfdZ3stE1MUxZ bh7Ed7k47BKmgC8qFCfALd65nkUPzSDpUDmagPhpKZKkvFSb2pm9n1BTQh6sABnqdWG8 mKuyumBXSm8A0IoEFmFmlYwKm+51TMTgOTmRBW8KaVZ+kVMOZ5Facq3iWoDrhc9Mx9Cm bkqHopNds3XHrWcZo4Pmg8m95jzB2dI8oG0jadp26SRo9mxEVWYJzopxScrlcfQa1Xd8 Ljx4/I81OajUZ3qlOJ2At/IQpvWwn0hmAY+Nu2PoSo7nwrU9A6EGqQLylB8+rsr5rgKx YxGg== X-Gm-Message-State: AOJu0YzySwvpwUBYq4SxZ3+pDDozvYb2lIwgyCJ0o+RAfdmHaYtf9cuy cJ4JJHOuuVzjbzDmAamgv/7TQgs7tcM= X-Google-Smtp-Source: AGHT+IHmJQHctKNoFbJtEwQ0ZN9pd/ErIGfIfxA2DgaglA0lvGMfaR9GBlWSL65RBP5sWPCAp2tp5A== X-Received: by 2002:ac2:4435:0:b0:500:a378:db71 with SMTP id w21-20020ac24435000000b00500a378db71mr3663849lfl.57.1698499337610; Sat, 28 Oct 2023 06:22:17 -0700 (PDT) Received: from [127.0.0.1] (cpc83311-brig21-2-0-cust191.3-3.cable.virginm.net. [86.20.40.192]) by smtp.gmail.com with ESMTPSA id dq4-20020a0560000cc400b0032326908972sm369661wrb.17.2023.10.28.06.22.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 28 Oct 2023 06:22:17 -0700 (PDT) Date: Sat, 28 Oct 2023 14:22:16 +0100 To: internals@lists.php.net User-Agent: K-9 Mail for Android In-Reply-To: References: Message-ID: <013A586C-26A9-454A-B855-E5474EB62B91@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary=----R0C4H131ABPJG9MWSM9TJ2BZ8W6R21 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Basic Type Alias From: rowan.collins@gmail.com (Rowan Tommins) ------R0C4H131ABPJG9MWSM9TJ2BZ8W6R21 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 26 October 2023 23:35:56 BST, Deleu wrote: >I would love it if we could bring up a discussion on proposing changes to >the PHP Namespace system to allow for something more like ESM while >considering we don't have a build system and a hot-reload system, but I'm >just not sure if PHP Type Aliases is where that discussion MUST to happen= =2E For those of us not familiar, can you provide a two or three line summary = of ESM, and what you think it provides that PHP currently lacks? As I understand it, the debate has generally not been about how *namespace= s* work, but about how *autoloading* works=2E The relevant parts being a) t= he ingrained culture of one definition per file (which is not a technical l= imitation, but makes certain coding patterns feel alien); and b) the lack o= f a universal build stage that can resolve symbols in advance (making it ha= rd to find a middle way between eager loading all possible definitions, and= postponing loading to runtime)=2E Luckily with a new concept like type aliases, we don't have the additional= problem that function and constant autoloading faces, of the dynamic fallb= ack to global scope=2E So as Mike Schinkel points out, it would be perfectl= y possible to have autoloaders that loaded one file per namespace rather th= an one per type name, with no changes to the core namespace or autoloading = system at all=2E In fact, it seems like a namespaced (rather than per-file) type alias woul= d *have to* use the exact same mechanism as classes etc, because the run-ti= me won't know it's a type alias until after it's loaded=2E For example, giv= en `function foo(\Acme\MyType $bar) { =2E=2E=2E }`, the runtime knows only = that `\Acme\MyType` is something that can describe a type, not whether that= is a class, interface, enum, or type alias=2E=20 Coming back to the lack of a build stage, that also means type aliases wou= ld be opaque to compile-time optimisations, which are mostly per-file=2E I'= m not sure what impact that would currently have, but it's worth thinking a= bout=2E Regards, --=20 Rowan Tommins [IMSoP] ------R0C4H131ABPJG9MWSM9TJ2BZ8W6R21--