[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Creating "echo" in GNU Smalltalk

From: Paolo Bonzini
Subject: Re: [Help-smalltalk] Creating "echo" in GNU Smalltalk
Date: Thu, 05 Oct 2006 13:31:18 +0200
User-agent: Thunderbird (Macintosh/20060909)

- How do I create a usable, distributable image without distributing
the source. (My source is hopelessly distributed over hundreds of
files with allot of secrets ;-) )
I'd not. Remember the "Scripting" part of GNU Smalltalk. But if you really want, create a class EchoMain, and add a method to get the #returnFromSnapshot update from ObjectMemory:

Object subclass: #EchoMain
      instanceVariableNames: ''
      classVariableNames: ''
      poolDictionaries: ''
      category: 'Language-Implementation'!

!EchoMain class methodsFor: 'foo'!

update: aspect
   aspect == #returnFromSnapshot ifTrue: [
       Smalltalk arguments = #('--repl') ifFalse: [
           self main: Smalltalk arguments.
           ObjectMemory quit ] ]!

main: argv
    "I love Java names!"
       do: [ :a| Transcript nextPutAll: a]
       separatedBy: [ Transcript nextPutAll: ' '].
   Transcript nl! !

ObjectMemory addDependent: EchoMain.
ObjectMemory snapshot: ''!

Run this script and it will create an image. If you have gst in your path, you can just do "chmod +x" and then "./ abc def".

I've placed a small hook, in that "./ --repl" will bring the standard read-eval-print loop up.
- How could I make it replace my current echo binary (although not
currently possible, without the extra flags). In short: make it
'self-contained' or executable.
If you have an image, of course it's just "cp /bin/echo" (not suggested :-). If you have a script, add "#! /usr/bin/env gst -f" at the head of it, or this:

#! /bin/sh
"exec" "gst" "-f" "$0" "$@"
PS and Offtopic: is there a way to load another image and call an
object within that image? Effectively using other images as libraries?
No, though in principle what you are describing is an RPC server.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]