From themarkitecht at gmail.com Tue Mar 16 22:40:30 2021 From: themarkitecht at gmail.com (Mark H) Date: Tue, 16 Mar 2021 17:40:30 -0500 Subject: [jimtcl] paradigm shift to run scripts from ROM (flash) Message-ID: Keeping y'all posted regarding this earlier thread: TheMarkitecht at gmail.com: ...a comprehensive solution. Such as: throughout jim.c, replace all char* function parameters with a new structure instead, such as "Jim_Text", which carries both the char* and the known length. That would mean basically a wholesale paradigm shift from C-style strings to known-length strings. You might say Pascal-style strings, but I wouldn't store the length at the front of the string data like Pascal does. That makes it too easy to overlook a piece of code that needed the rework, introducing insidious bugs. The new design should pass all existing test suites verbatim. patrick at spellingbeewinnars.org: I have wanted to do something like this too. I actually went through with that. Had to touch (I'm guessing) 75% of the lines of code in the Jim core. It took about 2 weeks. It actually works, using a handful of simple scripts. Didn't attempt the full Jim core test suite at that point. Took some measurements instead. It saved 14% RAM in my application on the STM32 MCU. Of course that depends heavily on the ratio of number of script lines to number of data objects (data working set size). Speed is within plus or minus 1% of Jim 0.79 when running on the PC. There are some side benefits. For example Jim's token parsing code got substantially increased readability. That's mainly done by replacing numerous occurrences of copy & pasted code with macro calls instead. If I recall, I reworked the core code, references code, and regex engine, and stopped after that for measurements. I tried Slim OOP on it (https://github.com/TheMarkitecht/slim). That still runs out of RAM, although it did manage to start that up without throwing errors, which is quite promising! Thoughts anybody? What should we do with that forked codebase? It's not posted anywhere but I might if there's interest. -- TheMarkitecht at gmail.com "GUI: (noun) - a method of organizing all my console windows." Slim OOP for Jim Tcl: https://github.com/TheMarkitecht/slim -------------- next part -------------- An HTML attachment was scrubbed... URL: