Hi Smalltalkers,
Development is progressing well for SmalltalkJVM, a Smalltalk on top
of the Java Virtual Machine that compiles to bytecode. I now call
this Smalltalk - Redline Smalltalk.
What I'm wanting is your opinion on the format of a Smalltalk source
file?
Some of what follows is my thinking aloud.
The format could be the same as the current "chunk" format but I feel
there should be an easier/simple way to write the source file, since:
1. The source will most likely be written outside of a traditional
Smalltalk IDE, via an Eclipse and IntelliJ plug-ins.
2. People should be able to use whatever editor they want and these
editors wont always know about chunk formats, meaning that if the
chunk format is used, people will have to do it manually.
3. There are some additional requirements on the source file to define
namespaces and import other classes (there is no single image file).
4. There is a need to have a format that works for scripts as well as
class definitions.
Here is an example of the Squeak Stack source in chunk format:
Object subclass: #Stack
instanceVariableNames: 'linkedList'
classVariableNames: ''
poolDictionaries: ''
category: 'Collections-Stack'!
!Stack methodsFor: 'accessing' stamp: 'dc 7/25/2005 10:04'!
size
"How many objects in me ?"
^ self linkedList size! !
-- end squeak stack example --
Some Thoughts:
T1. A benefit of keeping the chunk format would be for compatibility
with other smalltalks, like filing out of Squeak or VW and directly
into Redline.
T2. The comment "!Stack methodsFor:" would not be mandatory but would
be parsed if present. So when not present the only way to know a
method definition has ended is "! !"
I guess putting "! !" after a method definition is no harder nor clean
nor ugly as similar things in other languages like Ruby (def/end) or
Java ({}). Would you mind typing "! !" to end a method ?
Other things:
It is proposed that the class definition message format be extended to
support namespaces and importing of classes referenced by the current
class. For example, the above Stack definition becomes:
(Using suggestions from Nik
Boydhttp://www.educery.com/papers/sttojava/)
Object subclass: #Stack
instanceVariableNames: 'linkedList'
classVariableNames: ''
poolDictionaries: ''
packageName: #com:companyName:productName:packageName:
importPackageNamed: #java:awt:
importClassNamed: #java:util:Vector:
category: 'Collections-Stack'!
-- end --