I have about 1800 lines of GNU Smalltalk code I'd like to pull into Pharo. I've started doing it class by class, selector by selector, but it is very time consuming and tedious.
Is there a way to bulk import a project? I could easily adjust the format of the GST source files with vi
to be more Pharo-like beforehand.
Another thing I've considered is copying a "starter" .mcz
file, getting a feel for the format of the source.st
file, then creating a new source.st
with file cat
s and vi
. But then there's the snapshot.bin
file which seems also to have the source in it, making that a difficult path. It seems there should be an easier way. I've Google'd for it with different phrases but haven't hit anything.
Putting it in Monticello (.mcz) format is overkill for migrating. Just get it into fileout format (http://wiki.squeak.org/squeak/1105) and once you've loaded it into Pharo via filein, then you can create a Monticello package using the GUI if you want.
An quick way to see what fileout format involves (mainly just putting '!' in the right places):
Say you have two classes, LuckyClass1
a subclass of Object
and LuckyClass2
subclass of LuckyClass1
. And let's say your name is LuckyName
. And let's say you want to put your code into the package Lucky-Package1
.
Object subclass: #LuckyClass1
LuckyClass1 subclass: #LuckyClass2
Class LuckyClass1
with an instance side method luckyInstanceSideMethod1
, a class side method luckyClassSideMethod1
and instance side variable luckyInstanceSideVariable1
and class side variable LuckyClassSideVariable1
.
Similarly class LuckyClass2
with an instance side method luckyInstanceSideMethod1
, a class side method luckyClassSideMethod1
and an additional instance side variable luckyInstanceSideVariable2
and class side variable LuckyClassSideVariable2
.
Method references would look like this
LuckyClass1>>#luckyInstanceSideMethod1
LuckyClass1 class>>#luckyClassSideMethod1
LuckyClass2>>#luckyInstanceSideMethod1
LuckyClass2 class>>#luckyClassSideMethod1
On Linux/Mac OS X, do
vi Lucky-Package1-unix.st
to put in a file named Lucky-Package1-unix.st
something like
Object subclass: #LuckyClass1
instanceVariableNames: 'luckyInstanceSideVariable1'
classVariableNames: 'LuckyClassSideVariable1'
poolDictionaries: ''
category: 'Lucky-Package1'!
!LuckyClass1 methodsFor: 'lucky instance side protocol 1' stamp: 'LuckyName 6/8/2016 17:05'!
luckyInstanceSideMethod1
^ luckyInstanceSideVariable1 := 'lucky instance side'
! !
!LuckyClass1 class methodsFor: 'lucky class side protocol 1' stamp: 'LuckyName 6/8/2016 17:06'!
luckyClassSideMethod1
^ LuckyClassSideVariable1 := 'lucky class side'
! !
LuckyClass1 subclass: #LuckyClass2
instanceVariableNames: 'luckyInstanceSideVariable2'
classVariableNames: 'LuckyClassSideVariable2'
poolDictionaries: ''
category: 'Lucky-Package1'!
!LuckyClass2 methodsFor: 'lucky instance side protocol 1' stamp: 'LuckyName 6/8/2016 17:15'!
luckyInstanceSideMethod1
^ super luckyInstanceSideMethod1, ' subclass'
! !
!LuckyClass2 class methodsFor: 'lucky class side protocol 1' stamp: 'LuckyName 6/8/2016 17:17'!
luckyClassSideMethod1
^ super luckyClassSideMethod1, ' subclass'
! !
In fact, you can cut & paste the preceding block.
Then convert linefeeds to carriage returns or else Pharo will complain. This is important. If you are on Linux/Mac OS X you can use the following
cat Lucky-Package1-unix.st | tr \\n \\r > Lucky-Package1-pharo.st
On Windows I would still use bash, vi, cat, tr from git-scm https://git-scm.com/download/win
Then file in Lucky-Package1-pharo.st
. It should appear in the Lucky-Package1
package in System Browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With