MartinKoch123 / yaml

MATLAB YAML parser and emitter based on SnakeYAML
MIT License
22 stars 7 forks source link

Add option to convert YAML string to MATLAB char #14

Open Tinynja opened 7 months ago

Tinynja commented 7 months ago

Summary

I added the option StringToChar to load.m and loadFile.m, which lets the user choose if YAML String should be converted to MATLAB string (default, false) or MATLAB char (true).

Rationale

Depending on the context, MATLAB char are sometimes easier to manipulate than MATLAB string, especially in older versions of MATLAB. Therefore in many of my use cases, I found it useful to have an option to decide what should YAML String be converted to.

I can't imagine any YAML combination where using char would create a bug, because Sequences are converted to cell arrays, and Mappings are converted to struct, which both support char's correctly.

Feel free to change the name of the option or the implementation of the feature!

MartinKoch123 commented 7 months ago

Hi thanks for your efforts. However, I am not convinced yet, that this feature is necessary. The string type was introduced 8 years ago and in my experience they are way more convenient to use then chars in 99 % of cases. As for older Matlab versions, this package requires R2019b anyway. Can you describe the cases where you found it convenient to have chars in more detail?