Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111912 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 90699 invoked from network); 21 Sep 2020 22:41:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Sep 2020 22:41:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 93A18180510 for ; Mon, 21 Sep 2020 14:50:42 -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_20,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-Virus: No X-Envelope-From: Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 ; Mon, 21 Sep 2020 14:50:42 -0700 (PDT) Received: by mail-wr1-f43.google.com with SMTP id c18so14543662wrm.9 for ; Mon, 21 Sep 2020 14:50:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=TS7IuLRM/P6LY5sgP6ui8xCZZnHQWplSdqhhHAhOJyw=; b=LOzE4kNpPOddJr5T/w8ki3WyvSnxZmUrCcV6RAdG1N6sLcuT5VE494cR+n/CjomLKB jnMrusLwwlQJ17842hUROWzipKijtfF1q9GeQbZc9YH75zvbASMurkg3ZMlEcmzwT/6W l4kAPNM8HbQcybEmrCtTuVApebDJNUHTKWOZVVscPRiZsncvChDHzG6SSF4N0SrK2NOa kbki+/BYEwELj9taFXn31ol47TwaUMNaownVY+Rr4kI6AINb4f7Agq4rd+DieW5WQR9s O2Kob/2zXlWW7TYMb+1ZC/pcPPzwcb9K+7SqVExWxkh+SBJNuK2UZIlaZlKJwpBToiXL 8y9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=TS7IuLRM/P6LY5sgP6ui8xCZZnHQWplSdqhhHAhOJyw=; b=QS9asHcTdyDXcitnJB0gHJ34eXRZlkUfvmLWG+HqtR/fItxnUWw4c5sNfy+ayRyseo 4JVMH7z6xdoK6U+w+WvsWAZT9zfORxYNxPIyV19TnuZ2gIkvme8XT93RqYWq9MVT/4IY TdH2fCvYEQiUdFxi4W8wgg3MFCyuMUINhosxM4zAD5LiWAPoqzYSbn7Y0JDSgh5KVSrg DnrWT+Kk8zGqteUD1DxiOBki6tDGstey+FdDuap3RMYHuUcUkM95H9zL8xGV0NzpBg9b WbuTcbefpdZGZdn85c77zF24vJ1Z4MjqJvYbpoOiG3OM7s4Ele+9N5raKdwBBjj07OoN KBxw== X-Gm-Message-State: AOAM532dQGXTjAhTBSlxxVS7xZjRo1v3SGbIc30wswa9cXCQ43oGKnlG 1iwfaMioMPxZdVHhEzqL/6kR3wj7GuA= X-Google-Smtp-Source: ABdhPJwYlM3C602RrlalxCnz0zBVG4nqsOeZ3Y+1UkPGX6m/bc2ICIKaDPsykz2+vlQ7GN2lG4ts1w== X-Received: by 2002:adf:9e43:: with SMTP id v3mr1865734wre.306.1600725038455; Mon, 21 Sep 2020 14:50:38 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id f6sm22893905wro.5.2020.09.21.14.50.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Sep 2020 14:50:37 -0700 (PDT) To: internals@lists.php.net References: <994c6693-a405-ce0f-399c-1518a7eeb321@gmail.com> Message-ID: <4dc36ca7-3af5-fb53-521a-e7a85a5b4006@gmail.com> Date: Mon, 21 Sep 2020 22:50:34 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] Namespace-private class properties From: rowan.collins@gmail.com (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/structs/access-modifiers Regards, -- Rowan Tommins (né Collins) [IMSoP]