oforth words reference

Classes

ObjectObject.of
--- NullNull.of
--- OMNodeWord.of
------ AttribueWord.of
------ WordWord.of
--------- ImplementorWord.of
------------ ClassWord.of
------------ PropertyWord.of
--------- PackageWord.of
--------- FunctionWord.of
--------- ImplementWord.of
--------- MethodWord.of
--------- OperatorWord.of
--------- ConstantWord.of
--------- TVarWord.of
--------- AliasWord.of
--------- OSLibWord.of
--------- OSProcWord.of
--- SymbolWord.of
--- NumberNumber.of
------ IntegerInteger.of
------ FloatFloat.of
--- BlockBlock.of
--- Collectioncollect/Collection.of
------ Intervalcollect/Interval.of
------ Paircollect/Pair.of
------ Listcollect/List.of
---------- ListBuffercollect/ListBuffer.of
---------- Jsoncollect/Json.of
------ Setcollect/Set.of
------ Buffercollect/Buffer.of
--------- MemBuffercollect/Mem.of
--------- Stringcollect/String.of
------------ StringBuffercollect/StringBUffer.of
--- FileFile.of
--- Resourceresource/Resource.of
------ Consoleresource/Console.of
------ Channelresource/Channel.of
------ TCPSocketresource/TCPSocket.of
--------- TCPSocketServerresource/TCPSocketServer.of
--------- TCPSocketClientresource/TCPSocketClient.of
--- Taskparallel/Task.of
--- ExceptionException.of
------ ExCompilerException.of
------ ExRuntimeException.of
--------- ExBadTypeException.of
--------- ExIOException.of

Properties

ComparableComparable.of
RunnableRunnable.of
IndexableIndexable.of

Words that create new words

const: ( x "name" -- ) Creates a new constant with name "name" with value x
10 const: MYCONSTANT
asm.of
tvar: ( "name" -- ) Creates a new task variable with name "name"
tvar: MYVAR
asm.of
: ( "name" -- ) Creates a new function with name "name"
: square dup * ;
asm.of
method: ( cl "name" -- ) Creates a new implementation of method "name" for class cl
Integer method: and self ifFalse: [ drop false ] ;
asm.of
virtual: ( cl "name" -- ) Creates a new virtual implementation of method "name" for class cl
Integer method: and self ifFalse: [ drop false ] ;
asm.of
classMethod: ( cl "name" -- ) Creates a new class implementation of method "name" for class cl
Float classMethod: new 0.0 ;
asm.of
classVirtual: ( cl "name" -- ) Creates a new virtual class implementation of method "name" for class cl
Float classMethod: new 0.0 ;
asm.of

Immediate words

;C: ( -- )
R: ( -- )
End of function or method
: square dup * ;
prelude.of
returnC: ( -- )
R: ( -- )
Returns from current definition or current blockprelude.of
continueC: ( -- )
R: ( -- )
Continue the current loop
: test | i | 10 loop: i [ i 5 = ifTrue: [ continue ] i . ] ;
prelude.of
breakC: ( -- )
R: ( -- )
Immediately leaves from the current loop
: test | i | 10 loop: i [ i . i 5 = ifTrue: [ break ] ] ;
prelude.of
selfC: ( -- )
R: ( -- x )
Push the receiver of a method on the stack
Indexable method: first 1 self at ;
prelude.of
superC: ( -- )
R: ( -- x )
Call a method at the superclass level
A method: initialize super initialize 10 := a ;
prelude.of
ifTrue:C: ( -- )
R: ( b -- )
Generate a test between top of stack and true
: abs(n) n dup 0 < ifTrue: [ neg ] ;
prelude.of
ifFalse:C: ( -- )
R: ( b -- )
Generate a test between top of stack and falseprelude.of
ifNull:C: ( -- )
R: ( x -- )
Generate a test between top of stack and nullprelude.of
ifNotNull:C: ( -- )
R: ( x -- )
Generate a test between top of stack and nullprelude.of
ifZero:C: ( -- )
R: ( n -- )
Generate a test between top of stack and 0prelude.of
ifEq:C: ( -- )
R: ( x y -- )
Generate a test between the reference of the 2 objects on the stackprelude.of
else:C: ( -- )
R: ( -- )
Generate a block for the other part of a testprelude.of
=C: ( -- )
R: ( x y -- b)
Returns true if the two objects on top of stack are the same object (same reference).prelude.of
beginC: ( -- )
R: ( -- )
Beginnning of an infinite loopprelude.of
againC: ( -- )
R: ( -- )
End of an infinite loopprelude.of
whileC: ( -- )
R: ( -- )
Generates a while loop
: sumDigits(n) 0 while ( n ) [ n 10 /mod ->n + ] ;
prelude.of
doWhile:C: ( -- )
R: ( -- )
Generates a doWhile loop
: test 10 doWhile: [ dup . 1- dup ] ;
prelude.of
loop:C: ( "name" -- )
R: ( n -- )
Generates an integer loop from 1 to the top of stack
: test | i | 10 loop: i [ i . i 5 = ifTrue: [ break ] ] ;
prelude.of
for:C: ( "name" -- )
R: ( n m -- )
Generates an integer loop from n to m
: test | n | 5 10 for: n [ n . ] ;
prelude.of
forEach:C: ( "name" -- )
R: ( coll -- )
Generates a loop to traverse a collection
: test | n | 0 10 seq forEach: n [ n + ] ;
prelude.of
revEach:C: ( "name" -- )
R: ( coll -- )
Generates a loop to traverse a collection in reverse order
: test | c | "ABCD" revEach: c [ c emit ] ;
prelude.of
step:C: ( "name" -- )
R: ( n m s -- )
Generates a loop from n to m with step
: test | f | 1.0 2.0 0.1 step: f [ f . ] ;
prelude.of
try:C: ( "name" -- )
R: ( -- )
Generates a block that will catch exceptions
: test | e | try: e [ 1 0 / ] when: [ "div by zero catched" . ] "bye" . ;
prelude.of
assert:C: ( -- )
R: ( -- )
Beginning of an assert block. Assert block are only performed if --a command line option
: test(n) assert: [ n 0 > ] 2 + ;
prelude.of
#C: ( "name" -- )
R: ( -- r )
Retrieves word which name is the next string read and push it
: test 0 #+ 10 seq apply ;
prelude.of
#[C: ( -- )
R: ( -- r )
Creates a new block. If the block uses variables, creates a closure instead
: test 3 2 #[ * 1+ ] perform ;
Block.of
]C: ( -- )
R: ( -- r )
End of block or end of test of end of listprelude.of
->C: ( "name" -- )
R: ( x -- )
Store the top of the stack into local variable with name "name"
: sumDigits(n) 0 while ( n ) [ n 10 /mod ->n + ] ;
prelude.of
|C: ( -- )
R: ( -- )
Beginning and end of local variables definition
: test | n | 0 10 seq forEach: n [ n + ] ;
prelude.of
//C: ( -- )
R: ( -- )
Commentsprelude.of
--C: ( -- )
R: ( -- )
Commentsprelude.of
#!C: ( -- )
R: ( -- )
Commentsprelude.of

Stack manipulation

dup( x -- x x )Duplicates the top of stack
1 dup -> 1 1
prelude.of
drop( x -- )Removes the top of the stackprelude.of
swap( x y -- y x )Swap the two objects on top of stackprelude.of
over( x y -- x y x )Duplicate the second element on top of stack
1 2 over -> 1 2 1
prelude.of
tuck( x y -- y x y )Duplicate the top of stack under the second element
1 2 3 tuck -> 1 3 2 3
prelude.of
rot( x y z -- y z x)Rotate the 3 elements on the stack.
1 2 3 rot -> 2 3 1
prelude.of
-rot( x y z -- z x y )Rotate the 3 elements on the stack
1 2 3 tor -> 3 1 2
prelude.of
nip( x y -- y )Removes the second element of the stack
1 2 3 nip -> 1 3
prelude.of
2dup( x y -- x y x y)Duplicates 2 elements on the stack.
1 2 3 2dup -> 1 2 3 2 3
prelude.of
2drop( x y -- )Removes 2 elements from the stack.
1 2 3 2drop -> 1
prelude.of
clr( i*x -- )Empty the stackprelude.of
pick( i*x u-- i*x x )Retrieve element at index i on the stack
1 2 3 3 pick -> 1 2 3 1
prelude.of
.depth( i*x -- i*x u )Returns stack size
1 2 3 .depth -> 1 2 3 3
prelude.of

Other functions

test:( -- )Beginning of test block. This block is performed only if --t command line option
test: [ "abcd" first 'a' == ]
prelude.of
System.tick( -- n )Returns a tick in microseconds. Substracting 2 ticks gives an elapsed time in microseconds
: test: System.tick myFunct System.tick swap - ;
prelude.of
System.localTime( -- dst diff n )Returns current time (dst is the daylight saving time flag, diff is number of minutes between utc and local time, and n is the number of microseconds since 01/01/1970prelude.of

Object class (subclass of null)

Class Methods
new( aClass -- )Creates a new instance of aClass on the heap. #initialize is called.Object.of
allot( aClass -- )Creates a new instance of aClass in the dictionary. #initialize is called.Object.of
subclassResponsability(m)( x -- )Throws an ExRuntime exception.Exception.of
shouldNotCall(m)( x -- )Throws an ExRuntime exceptionException.of
Methods
classReturns object's class, instance of Class classObject.of
yourselfReturns the receiverObject.of
==Returns true if the two objects on top of stack are equals. Default checks if they are the same object.Object.of
<>Returns true if the two obejcts on top of stack are differents. Uses #==Object.of
<<(aStream)Sends the receiver on aStream and returns aStream on the stackObject.of
<< n(n, aStream)Sends the receiver n times on aStream and returns aStream on the stackObject.of
isNullReturns true if the receiver is the null objectNull.of
notNullReturns true if the receiver is not the null objectNull.of
doesNotUnderstand(m)Throws an ExRuntime exception. Called if the receiver does not understand mException.of
subclassResponsability(m)Throws an ExRuntime exception.Exception.of
shouldNotCall(m)Throws an ExRuntime exceptionException.of
isComparableReturns true if the receiver is ComparableComparable.of
isRunnableReturns true if the receiver is RunnableRunnable.of
isA(aClass)Returns true if the receiver is an object of class aClassWord.of
isKindOf(aClass)Returns true if the receiver is an object of class aClass or its superclassesWord.of
respondTo(aMethod)Returns true if the receiver respond to method aMethodWord.of
checkType(aClass, aString)Check if the receiver is of class aClass. If not, throw an exception with aString as messageWord.of
checkParent(aClass, aString)Check if the receiver class is a subclass of aClass. If not, throw an exception with aString as messageWord.of
isNumberReturns true if the receiver is a NumberNumber.of
isIntegerReturn true if the receiver is an integerInteger.of
isFloatReturn true if the receiver is a floatFloat.of
printPrint top on the stack on standard outputSystem.of
printlnPrint top on the stack on standard output, then new lineSystem.of
isCollectionReturns true if the receiver is a collection of objectsCollection.of
isIndexableReturns true if the receiver is IndexableIndexable.of
asListReturn a list with the receiverList.of
isStringReturns true is the receiver is a stringString.of

Null class (subclass of Object)

Class Methods
newReturns null objectNull.of
Methods
<<Sends "null" string the a streamNull.of

Comparable property

isComparableReturns true if the receiver is ComparableComparable.of
>Returns true if the second element is greater than the top of the stackComparable.of
<Returns true if the second element is smaller than the top of the stackComparable.of
>=Returns true if the second element is greater or equal than the top of the stackComparable.of
minReturns the minimum of the 2 first elementsComparable.of
maxReturns the maximum of the 2 first elementsComparable.of
between(a, b)Returns true if the receiver is between a and bComparable.of

Runnable property

isRunnableReturns true if the receiver is RunnableRunnable.of
times(n)Performs the receiver n timesRunnable.of
benchPerforms the receiver and print elapsed timeSystem.of
&Performs the receiver concurrently on a separate taskparallel/Task.of

Word class (subclass of Object)

Class Methods
newSend a shouldNotCall exceptionWord.of
find(aString)Returns word which name is aString, null if noneWord.of
Methods
nameReturns word name as a symbolWord.of
packageReturns word packageWord.of
alias:Creates an alias of the receiver with next word read on inputWord.of
<<Sends the receiver into a streamWord.of

Function class (subclass of Word)

Methods
type( f -- n )Returns function typeWord.of
isImmediate( f -- b )Returns true is the function is immediateWord.of
code( f -- addr )Returns function code addressWord.of
package( f -- aPackage )Returns word packageWord.of
perform( f -- )Execute the function on the stackWord.of
compile( f -- )Compile the function into the current definition.Word.of

Class class (subclass of Word)

Class Methods
@Immediate word : Generates a push of an attribute on the stackWord.of
:=Immediate word : Generates a set of an attribute with value on the stackWord.of
newPriority:Creates a new class with priority and superclass on the stack and next word as nameWord.of
new:Creates a new class with superclass on the stack and next word as nameWord.of
Methods
is:Add priority which name is next name to the receiverWord.of
nbAttReturns number of attributes of the classWord.of
superclassReturns superclass of the receiverprelude.of
attributesReturns a linked list of all attributes of the classWord.of
implementor(aMethod)Returns implemontor (class or property) of aMethod for the receiverWord.of
classImplementor(aMethod)Returns class implemontor (class or property) of aMethod for the receiverWord.of
isChildOf(aClass)Returns true if the receiver is a child of aClassWord.of
understand(aMethod)Returns true if the receiver understand aMethodWord.of
perform( m -- )Execute method mWord.of
compile( m -- )Compile method m into current definitionWord.of

OSProc class (subclass of Word)

( aOSProc -- )
Class Methods
new:( aLib n cl str "name" -- )Creates a new OSProc with into aLib library with n as number of parameters and str as proc name into the library.
LIBC 1 String "getenv" OSProc new: _getenv
Word.of
Methods
performPerform aOSProcWord.of

Number class (subclass of Object, Comparable)

Methods
isNumberReturns true if the receiver is a NumberNumber.of
<=Throw subClassResponsabilityNumber.of
+Throw subClassResponsabilityNumber.of
-Throw subClassResponsabilityNumber.of
*Throw subClassResponsabilityNumber.of
/Throw subClassResponsabilityNumber.of
asIntegerThrow subClassResponsabilityNumber.of
asFloatThrow subClassResponsabilityNumber.of
negReturns negate of the receiverNumber.of
sqReturns square of the receiverNumber.of
==0Returns true is the receiver is equal to 0Number.of
isPositiveReturns true is the receiver greater or equal to 0Number.of
isNegativeReturns true is the receiver smaller or equal to 0Number.of
sgnReturns the receiver sgn (-1, 0, 1)Number.of
absReturns absolute value of the receiverNumber.of
truncReturns integer part of the receiverFloat.of
ceilReturns next highest integerFloat.of
floorReturns next lowest integerFloat.of
roundReturns nearest integerFloat.of
sqrtReturns square root of the receiverFloat.of
invReturns inverseFloat.of
powReturns second element ^ topInteger.of
^Same as powInteger.of
powfReturns second element ^ top (exponent is a float)Float.of
rootReturns second element ^ inverse topFloat.of
lnReturns ln of the receiverFloat.of
logReturns log of the receiverFloat.of
expReturns exp of the receiverFloat.of
asRadianReturns radian value of the receiver (in degrees)Float.of
asDegreeeReturns degree value of the receiver (in radian)Float.of
cosReturns cosinus of the receiverFloat.of
sinReturns sinus of the receiverFloat.of
tanReturns tangent of the receiverFloat.of
cotgReturns cotangent of the receiverFloat.of
acosReturns arccos of the receiverFloat.of
asinReturns arcsin of the receiverFloat.of
atanReturns arctan of the receiverFloat.of
coshReturns hyperbolic cosinus of the receiverFloat.of
sinhReturns hyperbolic sinus of the receiverFloat.of
tanhReturns hyperbolic tangent of the receiverFloat.of
cothReturns hyperbolic cotangent of the receiverFloat.of
acoshReturns arc hyperbolic cos of the receiverFloat.of
asinhReturns arc hyperbolic sin of the receiverFloat.of
atanhReturns arc hyperbolic tan of the receiverFloat.of

Integer class (subclass of Number)

Class Methods
newReturns 0Integer.of
Methods
notReturn true if the receiver is false, false otherwiseBoolean.of
andAnd boolean operationBoolean.of
orOr boolean operationBoolean.of
xorXor boolean operationBoolean.of
bitAnd(aInteger)Performs bit and operation between the receiver and aIntegerInteger.of
bitOr(aInteger)Performs bit or operation between the receiver and aIntegerInteger.of
bitXor(aInteger)Performs bit xor operation between the receiver and aIntegerInteger.of
bitLeft(aInteger)Shift the receiver to the left aInteger timesInteger.of
bitRight(aInteger)Shift the receiver to the right aInteger timesInteger.of
isIntegerReturn true if the receiver is an integerInteger.of
==Returns true if the second element has the same value as the top of stackInteger.of
<=Returns true if the second element is less than the top of stackInteger.of
+Adds the two elements on top of stack.Integer.of
+Substracts the top of stack from the second elementInteger.of
*Multiplies the two elements on top of stack.Integer.of
/Divides the second element by the top of stackInteger.of
modReturns the remainder of the second element by the top of stackInteger.of
/modReturns the division and the remainder of the second element by the top of stackInteger.of
asIntegerReturns the receiverInteger.of
isMultiple(n)Returns true if the receiver is a multiple of nInteger.of
isEvenReturns true if the receiver is evenInteger.of
isOddReturns true if the receiver is oddInteger.of
gcdReturns gcd of the 2 elements on the stackInteger.of
lcmReturns lcm of the 2 elements on the stackInteger.of
pow // n a -- n^aReturns n^aInteger.of
^ Same as powInteger.of
nsqrtCalculate integer x / x*x <= self <= (x+1)*(x+1)Integer.of
<<cSends the receiver as unicode code to astreamInteger.of
<<wjpb(w, j, p, b)Sends formatted receiver to a stream (width, justify, precision, base)Integer.of
<<wjp(w, j, p)Sends formatted receiver to a stream (width, justify, precision)Integer.of
<<wj(w, j)Sends formatted receiver to a stream (width, justify)Integer.of
<<w(w)Sends formatted receiver to a stream (width)Integer.of
<<Sends formatted receiver to a streamInteger.of
isControlReturns true if the receiver is a control code (SPACE, DEL)Char.of
isLwSpaceReturns true if the receiver is SPACE or HTABChar.of
isSeparatorReturns true if the receiver is LwSpace or LFChar.of
isUpperReturns true if the receiver is an uppercaseChar.of
isLowerReturns true if the receiver is an lowercaseChar.of
toUpperReturns uppercase of the receiverChar.of
toLowerReturns lowercase of the receiverChar.of
isDigitReturns true if the receiver is a digitChar.of
isLetterReturns true if the receiver is a letterChar.of
isAlphaReturns true if the receiver is a letter or a digitChar.of
asIntegerOfBase(aBase)Returns integer value of the receiver into base aBase, null if noneChar.of
asDigitReturns integer value of the receiver , null if not a digitChar.of
asCharOfBase(aBase)Returns unicode code of the receiver into base aBase, null if noneChar.of
asCharReturns unicode code of the receiver, null if noneChar.of
randReturns random integer between 1 and the receiver (incuding the receiver)Float.of
seqEach(r)Apply r on each integers from 1 to the receiver.collect/Interval.of
asStringOfBase(aBase)Returns string representation of the receiver into base aBasecollect/StringBuffer.of
asFloatReturns float representation of the receiverFloat.of

Float class (subclass of Number)

Class Methods
newReturns 0.0Float.of
randReturns random float between 0 and 1 (excluding 0 and 1)Float.of
Methods
==Returns true if the two floats on top of stack have the same valueFloat.of
<=Returns true if the second element is less than the top of stackFloat.of
+Adds the two elements on top of stack.Float.of
+Substracts the top of stack from the second elementFloat.of
*Multiplies the two elements on top of stack.Float.of
/Divides the second element by the top of stackFloat.of
isFloatReturn true if the receiver is a floatFloat.of
asIntegerReturns integer representation of the receiverFloat.of
asFloatReturns float representation of the receiverFloat.of
negReturns the receiver negatedFloat.of
==0Returns true is the receiver is 0.0Float.of
isPositiveReturns true is the receiver greater or equal to 0Float.of
isNegativeReturns true is the receiver smaller or equal to 0Float.of
ceilReturns next highest integerFloat.of
floorReturns next lowest integerFloat.of
roundReturns nearest integerFloat.of
fracReturn fractional part of the receiverFloat.of
sqrtReturn square root of the receiverFloat.of
powfReturns second element ^ topFloat.of
rootReturns second element ^ inverse topFloat.of
lnReturns ln of the receiverFloat.of
logReturns log of the receiverFloat.of
expReturns exp of the receiverFloat.of
cosReturns cosinus of the receiverFloat.of
sinReturns sinus of the receiverFloat.of
tanReturns tangent of the receiverFloat.of
cotgReturns cotangent of the receiverFloat.of
acosReturns arccos of the receiverFloat.of
asinReturns arcsin of the receiverFloat.of
atanReturns arctan of the receiverFloat.of
coshReturns hyperbolic cosinus of the receiverFloat.of
sinhReturns hyperbolic sinus of the receiverFloat.of
tanhReturns hyperbolic tangent of the receiverFloat.of
cothReturns hyperbolic cotangent of the receiverFloat.of
acoshReturns arc hyperbolic cos of the receiverFloat.of
asinhReturns arc hyperbolic sin of the receiverFloat.of
atanhReturns arc hyperbolic tan of the receiverFloat.of
<<wjp(w, j, p)Send formatted receiver into a stream (width, justify, priority)Float.of
<<wj(w, j)Send formatted receiver into a stream (width, justify)Float.of
<<w(w)Send formatted receiver into a stream (width)Float.of
<<wSend formatted receiver into a streamFloat.of

System class (subclass of Object)

Functions
printPrint and remove top the stackSystem.of
.Print and remove top the stack and a space System.of
.crPrint and remove top the stack and and a CRSystem.of
.sPrint the stack, one object by lineSystem.of
.showRun .s after each command (run .show again to stop)System.of
.lPrint the stack, all objects on one lineSystem.of
memPrint memory used and memory allocatedSystem.of
byeReturns to OS with 0 as return valueSystem.of
Class Methods
microSleep(aInteger)Sleep the current task during aInteger microsecondsSystem.of
sleep(aInteger)Sleep the current task during aInteger millisecondsSystem.of
getTickGet a timestamp with 1 microsecond precision, used to calculate small durationsSystem.of
getTimeAndLocalGet number of microseconds since 01/01/1970, number of minutes between utc and local time, and daylight saving time flagSystem.of
getTimeGet number of microseconds since 01/01/1970System.of
memSizeReturns allocated memory (KBytes) and used memory (KBytes)System.of
getEnv(aString)Return value of environment variable which name is aString, null is noneSystem.of
cmd(aString)Perform aString as OS commandSystem.of
exit(aInteger)Return to OS with aInteger as return valueSystem.of
currentTaskReturns current task running.parallel/Task.of
suspendTaskSuspend the current task. This task will only resume using resume on the task objectparallel/Task.of

Collection class (subclass of Object)

td>Collection.of
Methods
isCollectionReturns true if the receiver is a collection of objectsCollection.of
sizeReturn collection sizeCollection.of
isEmptyReturn true if the receiver is emptyCollection.of
notEmptyReturn true if the receiver is not emptyCollection.of
firstReturn first object of the collection, null if noneCollection.of
secondReturn second object of the collection, null if noneCollection.of
lastReturn last object of the collection, null if noneCollection.of
apply(aRunnable)Apply aRunnable on all objects of the receiverCollection.of
applyr(aRunnable)Apply aRunnable on all objects of the receiver in reverse orderCollection.of
applyIf(aTest, aRunnable)Apply aRunnable on all objects of the receiver that respond true to aTestCollection.of
reduce(aRunnable)Push first element of receiver, then, for each other elements, push it and perform aRunnableCollection.of
count(aTest)Count number of elements that respond true to aTestCollection.of
detect(aRunnable, aObject)Return the first element of the receive that respond aObject true to aRunnableCollection.of
include(aObject)Return true if the receiver includes aObjectCollection.of
occurrences(aObject)Returns number of occurrences of aObject into the receiverCollection.of
conform(aTest)Return true if all elements of the receiver answer true to aTestCollection.of
maxFor(r)Return element with max value returned when r is appliedCollection.of
minFor(r)Return element with min value returned when r is appliedCollection.of
==(c)Return true if two collections are equal (ie with the same objects)Collection.of
<=(c)Return true if each element of c is <= to each element of the receiverCollection.of
sumReturn sum of all elements of the receiverCollection.of
prodReturn product of all elements of the receiverCollection.of
andReturn and of all elements of the receiverCollection.of
orReturn or of all elements of the receiverCollection.of
xorReturn xor of all elements of the receiverCollection.of
avgReturns average of all elements of the receiver. Return null if the collection is emptyCollection.of
keyAt(aKey)Return first element [key, value] into the collection where key == aKey. Return null noneyCollection.of
valueAt(aKey)Return value of first element [key, value] into the collection where key == aKey. Return null noneCollection.of
<<Send the receiver to a stream
asListReturn a list with all elements of the receiverList.of
asListBufferCreates a new listbuffer with all elements of the receiverListBuffer.of
map(aRunnable)Creates a new listbuffer with all elements of the receiver after applying aRunnable on themListBuffer.of
mapIf(aTest, aRunnable)Creates a new listbuffer with all elements of the receiver that respond true to aTest, after applying aRunnable on themListBuffer.of
+(aCollection)Return a new collection with all elements of aCollection and the receiverListBuffer.of
filter(aRunnable)Create a new collection with elements of the receiver that respond true to aRunnableListBuffer.of
reverseCreate a new collection with all elements of the receiver in reverse orderListBuffer.of
scan(aRunnable, aObject)Create a new collection with all intermediary results of applying aRunnable : aObject and first element, result and seconf element, ...ListBuffer.of
stripAll(aColl)Return a new collection after removing all elements included into aCollListBuffer.of
replaceValueAt(aKey, aValue)Return a new List after replacing value at aKey with aValueListBuffer.of
expandReturn a new List with all elements of the receiver and its sublistsListBuffer.of
groupWith(aRunnable)Return a new List grouping all adjacent elements of the receiver that respond the same value to aRunnableListBuffer.of
groupBy(r)Return a new List grouping all elements that respond the same value to r.ListBuffer.of
groupReturn a new List grouping all idenitical adjacent elements of the receiver into sulistsListBuffer.of
charsAsStringUse receiver elements as unicode code to create a stringStringBuffer.of
asSetCreate a set with all elements of the receiverSet.of

Indexable property

isIndexableReturn true if the receiver is IndexableIndexable.of
==Returns true if two indexables have the same size and the same elements at each indexIndexable.of
inRange(aInteger)Return true if aInteger is into the range of the receiverIndexable.of
firstReturn first element of the receiverIndexable.of
lastReturn last element of the receiverIndexable.of
indexOfFromTo(x, from, to)Return index of first occurence of x between from and to, null if noneIndexable.of
indexOfFrom(x, from)Return index of first occurence of x after from position, null if noneIndexable.of
indexOf(x)Return index of first occurence of x, null if noneIndexable.of
lastIndexOfFromTo(x, from, to)Return index of last occurence of x between from and to, null if noneIndexable.of
lastIndexOf(x)Return index of last occurence of aObject, null if noneIndexable.of
isAllAt(aColl, index)Return true if elements of aColle are all at index of the receiverIndexable.of
indexOfAllFrom(aColl, from)Return index of all elements of aColl into of the receiver after from, null if noneIndexable.of
indexOfAll(aColl)Return index of all elements of aColl into of the receiver, null if noneIndexable.of
zipWith(coll, r)Create a list with elements of the 2 collections after applying rListBuffer.of
zip(coll)Create a list with Pairs created using elements of the 2 collectionsListBuffer.of
unzipCreates two lists with a list of pairs, the first with the first elements, the second with the second elementsListBuffer.of
sortWith(aTest)Creates a list with all elements of the receiver sorted using aTestListBuffer.of
sortBy(aRunnable)Creates a list with all elements of the receiver sorted by the result of aRunnable applied to themListBuffer.of
sortCreates a list with all elements of the receiver sorted using #<=ListBuffer.of
sub(i, n)Creates a collection with n elements of the receiver from i indexListBuffer.of
extract(i, j)Creates a collection with elements of the receiver from index i to index jListBuffer.of
left(i)Creates a collection with i first elements of the receiverListBuffer.of
right(i)Creates a collection with i last elements of the receiverListBuffer.of
del(i, j)Creates a collection with all elements of the receiver but not the one from index i t index jListBuffer.of
replaceAll(source, target)Creates a collection after replacing all occurences of source by target elementsListBuffer.of
splitBy(n)Creates a list of collections, grouping elements n by nListBuffer.of
mapParallel(aRunnable)Perform aRunnable on each element of the receiver. Each calculation is done using a separate taskparallel/Task.of

Interval class (subclass of Collection, Indexable)

Functions
seqFrom(from, to)Creates a new interval of values between from and to, with step of 1Interval.of
seq(to)Creates a new interval of values between 1 and to, with step of 1Interval.of
Class Methods
newFromToStep(begin, end, step)Creates a new interval of values between begin and end, with step stepInterval.of
newFromTo(begin, end)Creates a new interval of values between begin and end, with step of 1Interval.of
Methods
sizeReturn interval sizeInterval.of
at(aInteger)Return interval value at index aIntegerInterval.of

Pair class (subclass of Collection, Indexable)

Methods
initialize(first, second) Creates new Pair [ first, second ] Pair.of
first Return first element of the receiver Pair.of
second Return second element of the receiver Pair.of
size Return 2 Pair.of
at(aInteger) Return element at position aInteger Pair.of
minKey(aPair) Given 2 pairs, returns the one which has the minimum key Pair.of
maxKey(aPair) Given 2 pairs, returns the one which has the maximum key Pair.of
minValue(aPair) Given 2 pairs, returns the one which has the minimum value Pair.of
maxValue(aPair) Given 2 pairs, returns the one which has the maximum value Pair.of

List class (subclass of Collection, Indexable)

Functions
listWith( i*x n -- aList )Creates a new list with n elements on the stackprelude.of
Methods
sizeReturn list sizeList.of
at(aInteger)Return element at aInteger position, null if noneList.of
asDateReturns new date from a list [ y, m, d, hh, mm, ss ]. If only 3 values, set hh, mm, ss to 0Date.of

Json class (subclass of List)

Methods
<<Send Json object to streamcollect/Json.of

ListBuffer class (subclass of List, Indexable)

Class Methods
newSize(aInteger) Creates a new listbuffer with aInteger space allocated ListBuffer.of
new Creates a new listbuffer ListBuffer.of
init(n, aRunnable) Creates a new listbuffer adding n times the result of performing aRunnabl ListBuffer.of
Methods
addAll(aCollection) Adds all elements of Collection into the receiver ListBuffer.of
add(aObject) Add aObject at the end of the receiver ListBuffer.of
put(aInteger, aObject) Put aObject at aInteger position of the receiver ListBuffer.of
removeAt(aInteger) Remove object at aInteger position and push it on the stack ListBuffer.of
removeFirst Remove first object and push it on the stack ListBuffer.of
removeLast Remove last object and push it on the stack ListBuffer.of
empty Empty the receiver ListBuffer.of
freeze Freeze the receiver which is converter into a List StringBuffer.of
freezeAsJson Freeze the receiver which is converter into a Json object StringBuffer.of

Buffer class (subclass of Collection, Indexable)

Functions
Buffer.utf8SeqSize(aInteger)Return UTF8 sequence size beginning by aInteger value (excluding this value), null if noneBuffer.of
Class Methods
newSize(aInteger)Creates a new buffer with aInteger bytes allocatedBuffer.of
newCreates a new bufferBuffer.of
Methods
basicSizeReturn number of bytes of the bufferBuffer.of
sizeReturn basicSizeBuffer.of
basicAt(aInteger)Return byte at position aInteger, null if none.Buffer.of
at(aInteger)Same as basicAtBuffer.of
utf8At(aInteger)Returns sequence size and unicode code at aInteger index of a UTF8 bufferBuffer.of

MemBuffer class (subclass of Buffer)

Methods
basicPut(aInteger, aByte)Put aByte at aInteger indexMem.of
put(aInteger, aByte)Same as basicPutMem.of

String class (subclass of Buffer, Comparable)

Methods
isString Returns true is the receiver is a string String.of
size Return number of utf8 characters into the receiver String.of
at(aInteger) Return utf8 character at aInteger position into the receiver. Position is based on UTF8 sequences String.of
hash Return a hash value of the receiver String.of
perform Perform an object into the string String.of
eval Perform an Oforth code into the string String.of
load Load file which name is the string String.of
== Return true if the second element is equal to the top of the stack String.of
<= Return true if the second element is smaller of equal to the top of the stack String.of
extractAndStrip(from, to) Extract substring [from, to] from the receiver and remove leading and trail spaces and control String.of
strip Return a new string with leading and trail spaces and control removed String.of
<< Send the receiver into a stream String.of
asIntegerOfBase(aBase) Convert the receiver into an integer of base aBase, null if conversion is impossible String.of
asInteger Convert the receiver into an integer, null if conversion is impossible String.of
asFloat Convert the receiver into a float, null if conversion is impossible String.of
asSymbol Return symbol corresponding to the receiver String.of
asClass Returns class which name is the receiver, null if none Word.of
asProperty Returns property which name is the receiver, null if none Word.of
asFunction Returns function which name is the receiver, null if none Word.of
asMethod Returns method which name is the receiver, null if none Word.of
asList Return a list with the receiver List.of
+ Return a new string after adding two strings StringBuffer.of
sortWith(aMethod) Sort the receiver using aMethod to compare characters StringBuffer.of
toLower Return lowercase string of the receiver StringBuffer.of
toLower Return uppercase string of the receiver StringBuffer.of
wordsWith(aChar) Return list of words separated by aChar into the receiver StringBuffer.of
words Return list of words separated by space into the receiver StringBuffer.of

StringBuffer class (subclass of String, Stream)

Methods
empty Empty the receiver StringBuffer.of
freeze Freeze the receiver which is converter into a String StringBuffer.of
addChar(aInteger) Adds unicode code aInteger at the end of the receiver StringBuffer.of
add(aInteger) Same as addChar StringBuffer.of
put(aInteger, aChar) Put character aChar at position aInteger StringBuffer.of
addAll(aCollection) Add all elements (as strings) of aCollection to the receiver StringBuffer.of

Set class (subclass of Collection, Indexable)

Methods
size Return set size Set.of
at(aInteger) Return element at aInteger position, null if none Set.of
add(aObject) Add aObject to the set. Do nothing if the object is alreay present int the set Set.of
addAll(aCollection) Add all elements of aCollection into the set Set.of
empty Empty the set Set.of
asList Returns an immutable list with elements of the receiver Set.of

File class (subclass of Object)

Class Methods
newMode(aString, aMode) Creates a new file with aString as file name. aMode is either File.BINARY, File.TEXT or File.UTF8 File.of
new(aString) Creates a new file with aString as file name and File.TEXT as file mode File.of
Methods
name Returns file name File.of
stats Retrieves file statistics : [ modified, created, size ]. Returns null if the file does not exist File.of
exists Returns true if the file exists File.of
size Returns file size File.of
created Returns file creation date File.of
modified Returns file modification date File.of
isOpen Returns true if the file is open, false otherwise. File.of
open(aAccess) Open the receiver. aAccess is either File.READ, File.WRITE or File.APPEND File.of
position Returns current file position File.of
setPosition(aOrigin, aOffset) Sets file position with aOrigin (File.BEGIN, File.CURRENT, File.END) and using aOffset integer from origin File.of
close Closes the receiver. If the file is already closed, do nothing. File.of
<< Sends the receiver to a stream File.of
readBytesWith(aSize, aMemBuffer) Populates aMemBuffer with aSize bytes from the receiver. If aMemBuffer is empty, creates a new memBuffer File.of
readStruct(aStruct) Creates and Populates aStructure with bytes from the receiver. File.of
>> Retreives next character from the receiver. If the file is open with File.UTF8 mode, retreives next unicode code from UTF8 sequence. File.of
readCharsWith(n, aStringBuffer) Reads n UTF8 characters from the receiver and append them to aStrinBuffer File.of
readChars(n) Reads n UTF8 characters from the receiver and returns the corresponding string File.of
readLineWith(aBuffer) Reads a line from the receiver and populated aBuffer. Returns the buffer or null if end of file File.of
readLine Reads a line from the receiver and returns a new buffer or null if end of file File.of
forEachNext Allows to use forEach syntax on files File.of
addChar(aInteger) Adds aInteger character to a file. If UTF8, uses aInteger as unicode code. File.of

Resource class (subclass of Object)

Methods
isOpen Returns true if the resource is open and ready for receive or send resource/Resource.of
select(aMode) Returns true if the resource is ready for aMode (Resource.RECEIVE or Resource.SEND) resource/Resource.of
isEmpty Returns true if the resource is empty resource/Resource.of
isFull Returns true if the resource is full resource/Resource.of
close Closes the resource Resource.of

Console class (subclass of Resource)

Methods
select(aMode) Returns true if the console is ready for aMode. If Resouce.RECEIVE, returns true if a key has been pressed resource/Console.of
sendChar(aInteger) Sends achar on console resource/Console.of
sendString(aString) Sends aString on console resource/Console.of
receiveTimeout(aTimeout) Waits until a key is pressed or timeout occurs (aTimeout is numbre of microseconds to wait). resource/Console.of
receive Waits until a key is pressed and return it. resource/Console.of
flush Flush all pressed keys from the console. resource/Console.of
ask Read a string from the console until CR is pressed and return it. resource/Console.of
askln Read a string from the console until CR is pressed and return it. Sends also cr. resource/Console.of

Channel class (subclass of Resource)

Class Methods
newSize(aSize) Creates a new channel with size aSize resource/Channel.of
new Creates a new channel with 200 as size resource/Channel.of
Methods
select(aMode) Returns true if the channel is ready for aMode (Resource.RECEIVE or Resource.SEND) resource/Channel.of
receiveTimeout(aTimeout) Waits until an objects is into the channel and receives it. Waits until aTimeout microseconds. resource/Channel.of
receive Waits until an objects is into the channel and receives it. resource/Channel.of
sendTimeout(aObject, aTimeout) Waits until the channel is no more full and send aObject. Waits until aTimeout microseconds. resource/Channel.of
send(aObject) Waits until the channel is no more full and send aObject. resource/Channel.of

TCPSocket class (subclass of Resource)

Methods
port Returns socket port resource/TCPSocket.of
select(aMode) Checks if the socket is ready for aMode (Resouce.RECEIVE or Resource.SEND) resource/TCPSocket.of
close Closes the socket resource/TCPSocket.of
<< Send the socket on a stream resource/TCPSocket.of

TCPSocketServer class (subclass of TCPSoket)

Class Methods
newBackLog(port, backLog, mode) Creates a new socket that will listen on port with backlog. mode is either TCPSocket.IPV4, TCPSocket.IPV6 or TCPSocket.IPALL) resource/TCPSocketServer.of
new(port) Creates a new socket that will listen on port with backlog 10 and mode TCPSocket.IPALL resource/TCPSocketServer.of
Methods
backLog Returns socket backlog resource/TCPSocketServer.of
acceptTimeout(aInteger) Accept new connections until timeout. WHen a new connection is coming, returns a new TCPSocketClient resource/TCPSocketServer.of
accept Accept new connections. WHen a new connection is coming, returns a new TCPSocketClient resource/TCPSocketServer.of

TCPSocketClient class (subclass of TCPSoket)

Class Methods
new(aHost, aRemotePort) Creates a new socket on aHost on remote service aRemotePort resource/TCPSocketClient.of
Methods
host Returns socket host resource/TCPSocketClient.of
remotePort Returns socket remote service resource/TCPSocketClient.of
connectMode(aMode) Connects the socket to remote host using aMode (TCPSocket.IPV4 or TCPSocket.IPV6 or TCPSocket.IPALL) and returns true or false resource/TCPSocketClient.of
receiveWithTimeout(aBuffer, aSize, aTimeout) Receives aSize bytes on the socket or abort if timeout occurs resource/TCPSocketClient.of
receiveWith(aBuffer, aSize) Receives aSize bytes on the socket resource/TCPSocketClient.of
receiveTimeout(aSize, aTimeout) Receives aSize bytes on the socket or abort if timeout occurs. Returns the string received resource/TCPSocketClient.of
receive(aSize) Receives aSize bytes on the socket. Returns the string received resource/TCPSocketClient.of
sendTimeout(aBuffer, aTimeout) Sends aBuffer on socket. Abort if timeout occurs resource/TCPSocketClient.of
send(aBuffer) Sends aBuffer on socket. resource/TCPSocketClient.of
<< Sends the receiver on a stream resource/TCPSocketClient.of

Task (subclass of Object)

Class Methods
newSize(aRunnable, aSize) Creates a new task with aRunnable, ready to be scheduled. This task will have a data stack of aSize size parallel/Task.of
new(aRunnable) Creates a new task with aRunnable, ready to be scheduled. This task will have a data stack of size 200e parallel/Task.of
Methods
runnable Returns task runnable parallel/Task.of
schedule Schedules the task. When a thread is available, the runnable will be performe on this thread. parallel/Task.of
resume Resumes a suspended task. parallel/Task.of
<< Sends the receiver on a stream parallel/Task.of

Emitter (subclass of Object)

Class Methods
new(aTimeout) Creates a new emitter. If aTimeout is not null, $timeout event is emitted if no event is emitted for aTimeout microseconds parallel/Emitter.of
Methods
isOpen Returns true is the emitter is open parallel/Emitter.of
onEvent(aEvent, aRunnable) Add aRunnable as listener to aEvent. Each time aEvent is emitted, aRunnable is launched parallel/Emitter.of
onEventParallel(aEvent, aRunnable) Same as onEvent, but aRunnable is launched into a separate task parallel/Emitter.of
emit(aEvent) Emit an event. All listeners on this event will be launched parallel/Emitter.of
close Closes the emitter parallel/Emitter.of

Logger (subclass of Emitter)

Class Methods
new(aName) Creates a new logger with aName as file name. parallel/Logger.of
Methods
log(aLevel, aObject) Logs aObject into the logger with aLevel level parallel/Logger.of
logInfo(*aObject) Logs aObject into the logger with info level parallel/Logger.of
logWarning(*aObject) Logs aObject into the logger with warning level parallel/Logger.of
logError(*aObject) Logs aObject into the logger with error level parallel/Logger.of

Exception class (subclass of Object)

Class Methods
throw Creates and throws a new exception Exception.of
Methods
initialize(aObject) Initialize a new exception with aObject as exception message Exception.of
throw Throws the receiver Exception.of
message Returns exception message Exception.of
<< Send an exception into a stream Exception.of
log Logs the receiver into System.Err Exception.of

ExRuntime class (subclass of Exception)

Methods
initialize(aMessage, aObject) Initialize a new exception with aMessage and aObject Exception.of
object Returns exception object Exception.of
<<(Stream) Send the receiver into aStream Exception.of

Oforth Documentation

Current available documentation :

I - Tutorials

  • Oforth basics : here
  • Oforth syntax : here
  • Writing Oforth programs : here
  • Oforth classes : here
  • Oforth parallelism : here
  • Oforth node : Work in progress...

II - Reference

  • Lang package reference : here