svenvc / ston

STON - Smalltalk Object Notation - A lightweight text-based, human-readable data interchange format for class-based object-oriented languages like Smalltalk.
MIT License
135 stars 32 forks source link

Improve the definition of legal characters in class names #29

Closed svenvc closed 3 years ago

svenvc commented 3 years ago

As remarked by @Rydier (Henrik Sperre Johansen) the definition of legal characters in class names is not well done.

STONWriter will write out any system class name, while STONReader has both an isClassStartChar: and isClassChar: that basically restrict class names to ASCII.

We need to figure out what would be the best way forward.

Note that there is no escaping mechanism in class names as there is for symbols.

svenvc commented 3 years ago

I guess the simplest possible change to the current code base (in Pharo) would be

STONReader>>#isClassStartChar: char
  ^ char isLetter and: [ char isUppercase]

STONReader>>#isClassChar: char
  ^ char isAlphaNumeric or: [ char = $_ ]

STONWriter could enforce this, but I am not sure this is needed, maybe a note is enough.

The specification (https://github.com/svenvc/ston/blob/master/ston-spec.md) should be updated as well.

astares commented 3 years ago

Just a side note: at the moment one can use class names (which are symbols) including valid parts like german umlauts like äöü and other. The system accepts them although one can use them not directly but indirectly in playground expression (one can use them using #asClass)

image

The current definition what is seen as valid name is in String>>#isValidGlobalName

image

svenvc commented 3 years ago

Ah OK, thank you, that is what I was looking for.

svenvc commented 3 years ago

I think thge following should work better:

https://github.com/svenvc/ston/commit/4c340158ad9d26edd43af8a6ac9a9325ce147873