Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111913 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40252 invoked from network); 22 Sep 2020 12:28:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Sep 2020 12:28:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 33D411804E3 for ; Tue, 22 Sep 2020 04:38:18 -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, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) (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 ; Tue, 22 Sep 2020 04:38:17 -0700 (PDT) Received: by mail-ej1-f65.google.com with SMTP id u21so22408323eja.2 for ; Tue, 22 Sep 2020 04:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=c0YZgqdubH9WrccEZBqn8xycqDZv69IOE8tz0/Tsvdc=; b=nbIoaho4Cl1qKKjNImEQTOM93qrlwDHFpZb1Zlg30lKKd6PGggK5i08/DbKRJEcwn0 BZhCgyxTlDOCISr5rGfEbZrqoc3WSSUHm3p2u7LH08BltXJETPs+7LUPd3ZZU9UWWpoU lsrV8acabXjKJZwXQu5Uz3jUKA2RVLSpgqb1t6YG6glysaFVv2Zs0yMGBzqNy8SN22GT COMbiqiOWLGZRQQQyuJEM/2kkjxmqdn6ojeri7XVpT216zxzguPfKC3MLlQpq0KfOFHH yp/wP1phS5tnG49I6Ldhw880M31TDnDOgNBccDGwWE+52fX3NEG02yB3dr/L5cjr7M67 GDfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=c0YZgqdubH9WrccEZBqn8xycqDZv69IOE8tz0/Tsvdc=; b=eI+j3KwbsvPgp368AWJWmyJtaQ1OPfF5s1Ugl9AFpHypYNZOAf82VOZPFiTb4uRiyv 78x0imuCxXsaFXl3e6BjoNGw46Mjq+hxulMsSVu++O4VTQLkg1jd6TCH383IO/pjRBBV TBIYVOEtqGaTy312kZyN7yqrYexEk0o4jNaugbY1/vnINkSOINomoQCJ1QD506IJXBZU v/ZfYHvCg2rj7L7cd208DC0Di/Ay8sLu1UvNBGYKhQ4fLPBweUn/2iLmW7pDBAnFKaaj fsfHwJCfnfktugA2YCN/DOIsa3Eie04g6138wBfbYi3mV/Rm7HbidmSW57yix3tel7zG hdvg== X-Gm-Message-State: AOAM533I05e3pJNfds1fV874uKvCzW5C5yBrDI43nl7uKhR834awmngP 3S6VwLIAuCEnpW3CJb3jGAdaYEVrfNHqF50/BB/sX//N X-Google-Smtp-Source: ABdhPJwr5d6YGLwTdSG3SjH6XT24Rk2vFqyjWngDrCiJW2rMAHgqO2ivObhBRgTUwtHyejoBhT4fRT3q+mYEVbJVZms= X-Received: by 2002:a17:906:ca8f:: with SMTP id js15mr4562580ejb.175.1600774696286; Tue, 22 Sep 2020 04:38:16 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a54:3ac6:0:0:0:0:0 with HTTP; Tue, 22 Sep 2020 04:38:15 -0700 (PDT) In-Reply-To: <4dc36ca7-3af5-fb53-521a-e7a85a5b4006@gmail.com> References: <994c6693-a405-ce0f-399c-1518a7eeb321@gmail.com> <4dc36ca7-3af5-fb53-521a-e7a85a5b4006@gmail.com> Date: Tue, 22 Sep 2020 11:38:15 +0000 Message-ID: To: Rowan Tommins Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Namespace-private class properties From: olleharstedt@gmail.com (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) 2020-09-21 21:50 GMT, Rowan Tommins : > On 21/09/2020 17:13, Michael Morris wrote: >> Next thing to consider - we have the problem of having already used the >> protected keyword in PHP, and honestly I prefer PHP's interpretation of >> the >> word. > > > I think it's actually Java that's the outlier here: PHP's meaning of > "protected" corresponds directly to C++, and to name a few I came upon > in a quick search it's also used that way by Kotlin [1], Scala [2], C# > [3] and Oxygene [4] - all of which use other ways to signal package > visibility: > > - Kotlin has a fourth visibility, "internal", meaning "public within > this module" > - Scala has an interesting syntax where you can modify the visibility > with the name of a package, as in "private[SomePackage]" > - C# adds *three* extra visibility modes: "internal", "internal > protected", and "private protected" > - Oxygene (a language I know next to nothing about) apparently has no > fewer than TEN modes, including both "assembly or protected" and > "assembly and protected" > > > All of which I think shows two things: firstly, that there are lots of > different ways to express this concept; and secondly, that there are a > lot of subtle combinations that might be useful. > > The C# list is particularly confusing, presumably because it's evolved > without a coherent plan. If I'm understanding correctly, C#'s "private > protected" corresponds to Oxygene's much clearer "assembly and > protected", while "protected internal" corresponds to "assembly or > protected". Considering those combinations up front might be sensible, > even if they're not implemented at once. > > > If we're considering using namespaces rather than a new package concept > for this, we potentially have a third dimension: is it private to _this > exact namespace_, or any "child" namespace starting with the same > prefix? Maybe something like Scala's modifier syntax might be more > useful, for instance: > > namespace Acme\Frobulator\Helpers\File; > class FileWidget { > private[namespace] $foo; // accessible specifically in the > "Acme\Frobulator\Helpers\File" namespace > private[Acme\Frobulator\Helpers\File\*] $bar; // accessible in this > namespace, and all sub-namespaces > private[Acme\Frobulator\*] $baz; // accessible in "Acme\Frobulator" > and all its sub-namespaces > } > > > [1] https://kotlinlang.org/docs/reference/visibility-modifiers.html > [2] https://www.tutorialspoint.com/scala/scala_access_modifiers.htm > [3] > https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-= and-structs/access-modifiers > [4] > https://docs.elementscompiler.com/Oxygene/Members/VisibilityLevels/struct= s/access-modifiers > > > Regards, > > -- > Rowan Tommins (n=C3=A9 Collins) > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > All good ideas, but I still don't know if PHP is aware of current namespace at all time? Anyone has this knowledge? It's a precondition to check namespace access. Olle