This thread has a huge discussion potential :) *grabs popcorn* On 8 December 2016 at 01:47, Torsten Bergmann <[email protected]> wrote:
> Hi, > > due to the absence of a namespace solution we today often prefix classes > with one, two or three letters. > You all know prefixes like "Zn", "Zdc", "GLM", "Tx", "WA", ... to avoid > conflicting names. > > I would like to have a "::" separator within the class name to better > distinguish > the class name from the prefix and increase readability at the same time. > SmalltalkMT > had this solution in alignment with C++ and I really liked working with it. > So much that I would like to see it in Pharo too - maybe also as a base > for future Namespace > additions. > > So I modified the #isValidGlobalName in Pharo 6.0 like mentioned below to > allow and support > the :: notation for classes. After that I can create classes like: > > Seaside::Component > Core::Boolean > Model::Person > GLM::BrickListModel > Tx::FontAttribute > > so far without any problem. > > Do you think > - there will be places where this conflicts or creates hazzles (tools, > metacello, ...) > - if it would be a good idea to add this to the default image? > > Thanks for feedback. > > Thx > T. > > ------------------------------------------------------------ > -------------------------------------- > isValidGlobalName > > self ifEmpty: [ ^ false ]. > > "reserverd default names" > self = 'NameOfSubclass' ifTrue: [ ^ false ]. > self = 'TNameOfTrait' ifTrue: [ ^ false ]. > > (self occurrencesOf: $:) = 2 ifTrue: [ > ^(self splitOn: '::') allSatisfy: [: part | part > isValidGlobalName ] > ]. > > ^ Character supportsNonASCII > ifTrue: [ > (self first isLetter > and: [self first isUppercase]) > and: [ self allSatisfy: [:character | > character isAlphaNumeric > or: [ character = $_ ]]]] > ifFalse: [ > (self first between: $A and: $Z) and: [ > self allSatisfy: [:character | > (character between: $a and: $z) > or: [ > (character between: $A and: $Z) > or: [ > (character between: $0 and: $9) > or: [ > character = $_]]]]]] > >
