-
Notifications
You must be signed in to change notification settings - Fork 123
Porting code from other Smalltalk dialects
Manfred Kröhnert edited this page Jan 11, 2014
·
16 revisions
Amber is different than other Smalltalk dialects in a few ways which makes porting code a non-trivial thing, but also quite manageable. Things you need to fix in MyCategory.st before it works:
- Rewrite character literals as single character Strings and make changes accordingly. Amber does not have Character, but String does implement some of Character behavior.
- Rewrite uses of class variables. Amber does support class instance variables, but not class variables.
- Rewrite uses of global variables. Amber only has global classes and packages, but not arbitrary objects. Use classes like
Smalltalk current
instead ofSmalltalk
etc. - Rewrite uses of pool dictionaries. Amber does not support them.
- Remove any pragmas. We will add support in the parser to just ignore them.
- Remove any
SystemOrganization addCategory:
chunks, Amber creates categories on the fly.
See: Slime Rules For Amber to automatically check these conflicts in Pharo/Squeak.
The current way to get code into Amber from another Smalltalk goes like this:
- After fixing the above things in your "other Smalltalk", export the code as a "fileout" in the chunk format with a .st filename extension. Make one file per class category and give it the same name as the class category - otherwise it breaks.
- Monticello style class extensions (loose methods) using
*yaddayadda
method category names are allowed. - Run
amberc MyCategorie.st
to compile it intoMyCategorie.js
. Put this file into the$AMBER/js
directory. - Edit the index.html file to load your code, and then open that file using for example [http://localhost:4000/index.html) and you should see the package called
MyCategorie
in Amber. In Amberclass categories
are called packages.
After this, pressing Commit package
should store any changes made (of selected package) back.
It also stores a corresponding MyCategory.st
file in the $AMBER/st
directory.
Oscar Nierstrasz started writing a tool for exporting Pharo packages to Amber. It can be found on SmalltalkHub and was announced on the Amber mailinglist.