Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The tonel format expects that the definition of a method is a sane superset of Pharo/Smalltalk.
The idea is that the resulting files looks like some classic source files from some classic programming languages that can easily be visualized, merged, hacked, etc. by humans. Instead of a random serialization format.
However, the current format cannot deal with method using some extended syntax that does not conform to the ad hoc rules of the tonel method content. Worse, tonel will blindly accept to save those methods not following those rules, thus creating files that won't be readable.
As a simple illustrative example, we can imagine weird fancy literals: for interpolation, for regex, for new separators that just will break the format. E.g
foo ^ '#[ $' ]'
orbar ^ ##/"hell/
orfoo ^ «french][style»
or whatever Pharo users want to experiment.Also, it cannot deal with methods containing some syntax errors without corruption of the whole file, thus preventing the reparation of the offending methods.
Because of the current format with
[]
and a content that must follow some specific matching rules, there is no easy way to adapt it to be compatible with an extended, more robust format.We want neither to change radically the format, nor losing the good human-related features.
Therefore, I propose a third approach: a specific degraded mode that is robust but only used if the tonel pure format is not usable.
For that, I reused a syntax I have seen in the CodeImporter with
!
as delimiter.So, If the format
method [ methodBody ]
cannot be used becausemethodBody
is not clean, the formatmethod !methodBody!
is used, where all!
present in methodBody are escaped (by doubling them, classic Pharo/Smalltalk idiom).Therefore,
methodBody
can contain any kind of garbage without breaking the whole file.Note that there is no loss of functionality, the alternative being a corrupted file