Torsten,

Because of the obvious portability problems this would introduce, I would think that an attempt should be made to come up with a common namespace solution ...

I do believe that some discussion about namespace alternatives has taken place between GemStone and Pharo --- not familiar with details or outcome of discussions, but I would like to think that at least an attempt was made to come up with a common solution before resorting to a unilateral solution that would only introduce more isolation between the various dialects --- something that a small community cannot really afford to do ...

Dale

On 12/07/2016 04:47 PM, Torsten Bergmann 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 = $_]]]]]]



Reply via email to