Smalltalk scripting (was Re: jpython anyone?)

ajalis at twu.net ajalis at twu.net
Tue Dec 12 01:17:40 UTC 2000


These syntax changes make smalltalk look frighteningly like C. 

Concerning the strangeness of the file-out format: For refugees from C
the file-out format's "strangeness" is precisely what makes Smalltalk so
appealing.  

The file-out format is also what Gnu Smalltalk also uses (I think).

Asim

On Mon, Dec 11, 2000 at 07:59:10PM -0500, Stephen Pair wrote:
> Now, the format of file-outs have everything we really need (ability to
> define classes and methods, execute code upon load...that's about it)...but,
> that format can be really strange to people not familiar with it...so
> perhaps the following syntax:
> 
> -----
> #!path/to/squeakscript
> 
> self requirePackage: '/path/to/otherpackage'.
> self requirePackage: 'packagename' version: '1.1'.
> 
> Object subclass: #Person
> 	instanceVariables: 'name address'
> 	classVariables: ''
> 	classInstanceVariables: ''
> 	poolDictionaries: ''.
> 
> Person defineMethods {
> 	name {
> 		^name
> 	}
> 	name: aString {
> 		name := aString
> 	}
> 	age {
> 		^age
> 	}
> 	age: aNumber {
> 		age := aNumber
> 	}
> }
> 
> Person class defineMethods {
> 	new {
> 		^super new
> 			name: '';
> 			age: 0;
> 			yourself
> 	}
> }
> 
> self class defineMethods {
> 	blahName: name age: age {
> 		name blah: age.
> 	}
> 
> 	main {
> 		| foo bar helperFunc person |
> 		"Declare the vars you need!"
> 
> 		foo := stdin inputWithPrompt: 'Enter name: '.
> 		bar := stdin inputWithPrompt: 'Enter age: '.
> 		person := Person new
> 				name: foo;
> 				age: bar;
> 				yourself.
> 
> 		stdout show: (self blahName: person name age: person age).
> 	}
> }
> 
> self main.
> -----
> 
> Now, main is not strictly needed, but it might be good coding practice to
> place the meat of your code inside of methods rather than hanging loose in
> the script.  The "{" would be an indication to the parser that the result of
> the previous statement should parse the next chunk of text up to the closing
> "}"...similar to the working of the current file-out, but usings notation
> that might be more comfortable to some people.  Also, lines beginning with
> "#" would simply be ignored.
> 
> 
> - Stephen





More information about the Squeak-dev mailing list