[squeak-dev] How to use OSProcess with stdin and stdout
K K Subbu
kksubbu.ml at gmail.com
Sat May 23 11:58:44 UTC 2020
On 23/05/20 2:05 am, Martin Kuball wrote:
> Hi David,
>
> I finally found a solution to my problem. Successfully converted 1300 images in
> a couple of minutes. The code I come up with is roughly the following (using
> the wc program here as a proof of concept before switching to tesseract and
> image data for the input):
Very nice! You could also look at waitForCommand: which spawns an
external process and waits for its completion.
> Mybe it is possible to reuse more of your high-level code. But I wanted low
> overhead and complete control over the input and output streams.
Squeak is not just an application running on the host. It is a whole
virtual machine. You have to think of the host as another node in a
network. Using stdin/stdout makes Squeak process a co-routine with the
host process and be prepared to handle SIGPIPE etc. You may not want
such close coupling.
Back in 2008-09, students (11-13yrs) wanted to use Etoys/Squeak to
practice Math and languages with complex scripts (Hindi, Kannada) that
only LaTeX supported. Simon Guest had written a LatexMorph for
processing simple LaTeX code on host. I improved it to handle complex
Indic scripts. Students would type LaTeX sentences in a text morph.
LatexMorph would save this string in a file, run latex and dvipng to
produce an image and read it back as an ImageMorph. It was a hack using
just OSProcess waitForCommand: and tmpfs (to avoid disk i/o) but it fast
enough for live LaTeX renders and even teachers took to it. We sure had
a lot of fun with it.
See https://squeaksource.com/LatexMorph (~ 500 lines of Squeak. The
operative LatexUnix class is only around 50 lines). I can send you the
changeset if you are interested.
HTH .. Subbu
More information about the Squeak-dev
mailing list
|