Many years ago there was a proposal in the Squeak mailing list about enforcing a naming convention, "pvt", I implemented that in my Smalltalk system. The compiler enforces the rule that pvt.[A-Z].* message can only be sent to (self|super) (basicNew|basicNew: n|new|new: n|pvtNew: n)? in a class method or (self|super) ((class (new|new: n)|pvtSpeciesNew: n|pvtClone)? in an instance method. There are currently 9412 public selectors 793 pvt* selectors and 23 private* selectors, where the last group is methods that I *want* to be private in some sense but cannot do with this machinery. (For example, calling a "private" method on another object known to be of the same class.)
I think the evidence shows that this works well enough to be useful, even if it isn't quite as expressive as I'd like. And what *that* means is that this can be done with a style check, using the machinery Pharo already has for style checks. On Wed, 18 Aug 2021 at 08:14, Craig Johnson <cr...@hivemind.net> wrote: > > Hi All, > > > Just a newb off-the-wall question. > > Is there any good reason why we can't create a true private method in a > Pharo class by putting that method inside an instance or class variable > as a lambda (block). > > > This would reduce one of my biggest bugbears with Pharo, namely the > pollution of the global namespace with every single message name in the > entire system. > > > > Craig