GNU Smalltalk: Difference between revisions

m
Use the implementation template, removed link to "hello world"
m (Use the implementation template, removed link to "hello world")
Line 1:
{{implementation|Smalltalk}}'''GNU Smalltalk''' is an implementation of the [[:Category:Smalltalk|Smalltalk]] programming language by the GNU Project. For download, see [http://smalltalk.gnu.org/ http://smalltalk.gnu.org/].
 
The implementation, unlike other Smalltalk environments, uses text files for program input and interprets the contents as Smalltalk code. In this way, GNU Smalltalk acts more like an interpreter rather than an environment in the traditional Smalltalk manner.
 
==Examples==
These examples only work on GNU Smalltalk 3.0 and later versions. Classic [[Hello world]] example:
 
'Hello World!' displayNl
Line 92:
"=> 6"
 
A method such as ''inject:into:'' can accept both a parameter and a block. It iterates over each member of a list, performing some function on while retaining an aggregate. This is analogous to the [[foldl]] function in [[Haskell]]. For example:
 
#(1 3 5) inject: 10 into: [ :sum :element | sum + element ] "=> 19"
Line 115:
===Classes===
 
The following code defines a class named Person. By deriving from Magnitude, it automatically defines all comparison methods except one (<code>&lt;</code>). With the addition of that one, <code>asSortedCollection</code> can sort by age. Note that we can override the way the object is printed/displayed (the default is to share the programmer-print and user-display representation) by overriding <code>printOn:</code>.
 
Magnitude subclass: Person [
Line 184:
* [http://www.gnu.org GNU]
* [http://smalltalk.gnu.org/ GNU Smalltalk]
 
[[Category:Smalltalk Implementations]]
Anonymous user