Can I launch Squeak as a REPL (no GUI), where I can enter and evaluate Smalltalk expressions? I know the default image don't allow this. Is there any documentation on how to build a minimum image that can be accessed from a command-line shell?
相关问题
- Simple class definition error in smalltalk
- Which Smalltalk object should be passed to a C fun
- Squeak(smalltalk) subSrings ignores empty strings
- Smalltalk variables: why should I declare them?
- How to manage 2d array in Smalltalk?
相关文章
- Implementation Strategies for Object Orientation
- What is the difference between Seaside programmmin
- How to copy several Monticello commits from local
- Smalltalk ReferenceStream has problems with new in
- Is it possible to write shell command within Pharo
- Draw table in Pharo
- Draw table in Pharo
- Double dispatch in Pharo
Here is a (hackish) solution: First, you need OSProcess, so run this in a Workspace:
Next, put this in the file repl.st:
And last, run this command:
You can now have fun with a Smalltalk REPL. Dont forget to type in the command:
if you want to save your changes.
Now, onto the explanation of this solution: OSProcess is a package that allows to run other processes, read from stdin, and write to stdout and stderr. You can access the stdout AttachableFileStream with
OSProcess thisOSProcess
(the current process, aka squeak).Next, you run an infinite loop at userBackgroundPriority (to let other processes run). In this infinite loop, you use
Compiler evaluate:
to execute the input.And you run this in a script with a headless image.
The project http://www.squeaksource.com/SecureSqueak.html includes a REPL package that may provide much of what you are looking for.
Please visit: http://map.squeak.org/package/2c3b916b-75e2-455b-b25d-eba1bbc94b84 and Run Smalltalk on server without GUI?
As of Pharo 2.0 (and 1.3/1.4 with the fix described below), there are no more hacks necessary. The following snippet will turn your vanilla Pharo image into a REPL server...
From https://gist.github.com/2604215:
If you want the image to always be a REPL, put the code in a #startup: method; otherwise, pass the script at the command line when you want REPL mode, like: