Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115885 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 42561 invoked from network); 27 Aug 2021 19:13:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Aug 2021 19:13:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E9B7D1804B3 for ; Fri, 27 Aug 2021 12:47:56 -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=-0.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 27 Aug 2021 12:47:56 -0700 (PDT) Received: by mail-lj1-f175.google.com with SMTP id m4so13313559ljq.8 for ; Fri, 27 Aug 2021 12:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=D4ZPY/Aj1CZGip+LsrvWTfd/1bNVdQhOgTFT2v+sELo=; b=oKH2V8EZh2dzdRmF0ffCHG2fp5FZtEQdYzEDFm46w2QtkUvW2s27HBzge+Fca+fhPt 9NN+/GvkU4kdrAv2dGaMoF0xGQhlI1VqktnbzFwYEk8EiG0kCHkuZKdCnK1tfRpE2Vzs 7RuW7/Wk1CpmYgRyqN1C22jGNQ1A3OEGD7kf+HJrbOTemjcY08v4VSNrSPHT8wq2uxox 0Ot7SIoLLhf37+dx5Sae/xjyc/HcNjJidWmZv0LgKLbReMOgI5E6oTa+V7lInyRgSb6x +yY/LkQ9KEd0p+Sz6rx3dadd1UTBISYDPoOAdFG10Etfu02ZFmvSt+QQ90LctCCMq7sE ywIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=D4ZPY/Aj1CZGip+LsrvWTfd/1bNVdQhOgTFT2v+sELo=; b=WZsMqch5ToSUm99CI9O9kb+4GUUsc6Jb7AXCBYP1NZh2P95zg4fWXRhozDnpAiG1dO 1kkeAWGD6M19eG89x1BGCoyMGii0wBp0wwIA9ul+XKiPjseglr1+WEytCtz/0nmHszM8 4boEWQ/AvtvCiGFWDAiuTBb87r7fH3lXKQIXa/M9rWBmZ4N4AQHy4ORMunpd86KKZIB2 e0dBmiYJtCVTkYCdCp9Y6EjX/rwP5VvL309AjK6hooJTQ4nzyBlP+8rvjrlp2Uf+P6x/ 3t3oJmF09jDqcGtpVj2w/CMdDY1Covyzs8+5r0Fl/YsLEw/UvijQUotXMfkcXAaJM++L SPtA== X-Gm-Message-State: AOAM533qd/02JO7QnDE6rB0UVENCsrJEWuwDLlrCRGu43g2eYbCNzPsc IB0i1F9r3rKenkeSDfcV0Yewgq38CK1Nw+kFvb0lYgEFnfI= X-Google-Smtp-Source: ABdhPJxqinxZmvtOax+1WIydZ08iCGY/BAVXLgJb1BFOb1DpbQZgt0QQ/BxWZ30iGdHrKUIBmFvo6O5gMeWC2mQGeUY= X-Received: by 2002:a2e:bd13:: with SMTP id n19mr9110109ljq.175.1630093674649; Fri, 27 Aug 2021 12:47:54 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab3:6384:0:0:0:0:0 with HTTP; Fri, 27 Aug 2021 12:47:52 -0700 (PDT) Date: Fri, 27 Aug 2021 21:47:52 +0200 Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Make namespace part of runtime From: olleharstedt@gmail.com (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) Hi, As a followup for my previous post, I think this could be a good place to start to enable attribute writers to create encapsulation mechanics for composition, like namespace visibility, "internal" access or friend classes. There's an outline to an idea by Nikic here: https://github.com/php/php-src/pull/947#issuecomment-224934615 > In principle this should be relatively simple: Introduce a struct _zend_n= amespace { zend_string *name, uint32_t start; uint32_t end; } structure (wh= ere start/end are opline offsets), and store an array of these in the op ar= ray. Usually this array will have only a single element (or be empty). Gene= rating and storing this data should be relatively simple. The most difficul= t part is probably adding support for this structure in the opcache optimiz= er (particularly the block pass), but this can later be done by someone els= e, who is familiar with the component. The missing part is exposing it to attribute authors using a magic constant like __NAMESPACE_RUNTIME__, reflection, or something else I didn't think of. :) Eventually, idiomatic attributes could be made part of the core language as new keywords, for performance reasons (instead of #[Internal] attribute, add an "internal" keyword, and so on). Good idea or bad? Olle