albertodemichelis / squirrel

Official repository for the programming language Squirrel
http://www.squirrel-lang.org
MIT License
926 stars 161 forks source link

squirrel port to raspberry pi pico #279

Open byzantic opened 1 year ago

byzantic commented 1 year ago

Not really, an issue, so feel free to close ..

I just got squirrel 3.2 running on a pi pico, using a hacked version of the sq example interpreter shell. I had to chop out the cli argument part and always run the interactive loop. minicom also sends \r rather than \n, so I had to accept that as an end of line marker as well. (Yes, I know you can set up a translation config .. but ..)

I did have few issues with the stdio on the pico - some functions write to stdio with no buffering, whereas others (notably the f variants) need an fflush. This seems to be a known issue.

However, sq is still pretty rudimentary, and the inability to load a file means that it's a bit difficult to do much more than one-liners.

As an aside, if one uses a style where function definitions use a { on the same line as the function definition, you can paste a whole function definition in from the terminal.

sq> function mysq(b) {
            return n * n;
}

In fact, if you put an entire program in curly braces, this will also work.

To go much further one would need a more capable interpreter and/or pc-side driver program, in the same vein as micropython. Anyone know of a library that provides that sort of facility?

I suppose one might go a different way, and embed squirrel into micropython somehow, so that one can re-use the repl and file system facilities, though that seems a bit obtuse ..