Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failsafe tonel #108

Open
wants to merge 2 commits into
base: Pharo12
Choose a base branch
from
Open

Failsafe tonel #108

wants to merge 2 commits into from

Conversation

privat
Copy link

@privat privat commented Apr 14, 2023

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 ^ '#[ $' ]' or bar ^ ##/"hell/ or foo ^ «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 because methodBody is not clean, the format method !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

@jecisc
Copy link
Contributor

jecisc commented Sep 15, 2023

I updated the PR to go against the new Pharo12 branch.

Copy link
Contributor

@jecisc jecisc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this interesting. What do you think @estebanlm ? Can we merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants