I think there are two good answers:
FileStream fileIn: 'afile.st'.
In GNU Smalltalk, you do not import / include / do not require one source file in another source file.
Explanation of the first answer
Suppose I have a file foo.st:
"foo.st"
Object subclass: Foo [
foo [^ 'I am Foo from foo.st']
]
Foo , bar.st, FileStream fileIn: 'foo.st' init Bar:
"bar.st"
Object subclass: Bar [
| barsFoo |
Bar class >> new [
| r |
r := super new.
^ r init.
]
init [
"Combines the contents of foo.st with the current image
and assigns a new Foo to barsFoo."
FileStream fileIn: 'foo.st'.
barsFoo := Foo new.
]
bar [
^ 'I am bar from bar.st'
]
foo [
^ barsFoo foo.
]
]
:
$ gst
GNU Smalltalk ready
st> FileStream fileIn: 'bar.st'
FileStream
st> b := Bar new
a Bar
st> b foo
'I am Foo from foo.st'
/include/require. , FileStream fileIn: 'foo.st' init , :
st> f := Foo new
a Foo
st> f foo
'I am Foo from foo.st'
, Foo bar.st, , FileStream fileIn: 'bar.st' bar.st .
GNU Smalltalk . Smalltalk - , , GNU Smalltalk, Smalltalk. IDE . , Smalltalk GNU Smalltalk .
, Bar Foo , Foo:
$ gst
GNU Smalltalk ready
st> FileStream fileIn: 'foo.st'
FileStream
st> ObjectMemory snapshot: 'foo.im'
"Global garbage collection... done"
false
st>
, Foo:
$ gst -I foo.im
GNU Smalltalk ready
st> f := Foo new
a Foo
st> f foo
'I am Foo from foo.st'
Foo Bar, init :
init [
barsFoo := Foo new.
]
Foo Bar:
$ gst -I foo.st
GNU Smalltalk ready
st> FileSteam fileIn: 'bar.st'
FileStream
st> ObjectMemory snapshot: 'foobar.im'
, :
Object subclass: FooBarBuilder [
FooBarBuilder class >> new [
| r |
r := super new.
^ r init.
]
init [
FileStream fileIn: 'foo.st'.
FileStream fileIn: 'bar.st'.
]
]
:
$ gst
GNU Smalltalk ready
st> FileStream fileIn: 'foobarbuilder.st'
FileStream
st> ObjectMemory snapshot: 'foobar.im'
"Global garbage collection... done"
false
st>
foobar.im Foo Bar FooBarBuilder. kludgey, .
(foo.im, foobar.im) GNU Smalltalk "" Smalltalk. package.xml:
<package>
<name>FileImport</name>
<file>foo.st</file>
<file>bar.st</file>
<file>foobarbuilder.st</file>
<filein>foo.st</filein>
<filein>bar.st</filein>
<filein>foobarbuilder.st</filein>
</package>
- "" , GNU Smalltalk gst-package. home Linux, (/usr/share/gnu-smalltalk/ Ubuntu 16.04):
~/smalltalk/fileimport$ gst-package -t ~/.st package.xml
~/smalltalk/fileimport$ gst
GNU Smalltalk ready
st> PackageLoader fileInPackage: 'FileImport'
"Global garbage collection... done"
Loading package FileImport
PackageLoader
st> Foo new
a Foo
st>
. GNU Smalltalk -, . , , .
. - Smalltalk IDE, , - .