The Funge 98 definition is by definition imperative, iterative, and in no way modular except through the use of fingerprints. The fingerprint, however, was limited and unspecified. The difficulty in designing an OOFTL is that if the same approach is used to transform Funge into OO as was used for other languages such as C and *cough* Turing, you would lose all the unique advantages (and eccentricities) of Fungoids. A slightly different approach is necessary. You are limited to either a set length of instruction or an instruction delimiter. I feel that the delimiter approach is better for flexibly and future expansion, but it strays from the spirit of Funge and makes the code less understandable in a typical text editor. OOFTLUN will have a set length of instruction. Funge 98 had a length of one character per instruction which allowed the construction of trivial (Hello world!) to only semi-trivial (guessing game) programs. Assembly code instructions are usually three to four characters. Funge is, in its own way, assembly code for a virtual Funge machine. OOFTLUN will have instructions of length three or four. White space is permitted in an instruction name, but I would not suggest creating less than three letter instructions. All predefined instructions are four letters and all user defined instructions are three letters.
Data types in Funge 98 were char and int, or instruction, char, and int since an instruction is a character. The char is easily converted to and from integers, so the very basic type of Funge could be said to be an integer treated differently depending on the context. A thread's memory is stack based. F98 introduced stack stacks. The basic data type in a stack is integer in F98. The basic data types in OOFTLUN are double, instruction, and an instance of a (fingerprints?) data space. From an OOFTLUN programmer's viewpoint an instruction is simply four characters that refers to a predefined instruction or an imported instruction. From an OOFTLUN interpreter viewpoint, an instruction is a pointer to the cell in a subspace with (sometimes) new properties to continue executing from, and an instance of a (fingerprints?) data space is simply a warp to the first node of data. All the normal data types can by reproduced from doubles and the creation of various (fingerprints?) (stack stack, string...).
Every OOFTLUN code file (*.f) has a definition file (*.fd) that corresponds to it. The .fd contains information such as what (fingerprints?) to load, what areas are designated static/non-static, public/private(/protected), and code/data area. In addition, it designates the edge delimiters (default are chars 13, 12) in the .f and the characters to ignore in the processing of the .f (default char 10). The .f is strictly code, and comments if the programmer wishes. Code is by default private and non-static to other (fingerprints?), and public and static to itself. Data is private to other (fingerprints?) by default. No code or data is orthogonaly persistent (i.e. modification of the code is not remembered after the last instance is terminated (i.e. the program closes, the changes to any public or private data is reset, not saved to file)). It is possible to implement this persistence behaviour in a (fingerprint?) though.
Tabs and spaces will exist only as place holders by the interpreter/compiler. They can act as delimiters for instructions of less than length four. Multiple white spaces will be counted as one (i.e. four spaces does not count as an instruction).
Execution of program flows like this:
Each thread in OOFTLUN has its own stack. A stack element may be a double, an instruction or a space of data for a (fingerprint?). Copying a data member creates a new instance of the data section(s) of the (fingerprint?). The constructor is called for the new instance, then the data of the new copy is overwritten. The copies are identical at that instant, but are independent.
The general properties of OOFTLUN are: stack based, multi dimensional, multi directional, self mod, fixed length instructions, wrapping, and OO.
A delta is given to each thread. By default it is [1,0,...0]. Each part of the vector may be any double. If any are not integers, then a probabilistic execution of the current instruction will occur according to:
where deltaK is the Kth element of the delta (zero based index) and D is the dimension of the current space, P is the probability that the current instruction will be executed.
A cell may contain:
A warp is a reference to a new instruction in one of the (fingerprints?) given in the current space's .fd. A warp may be into another space, or it may be into the current space.
A fingerprint can be any .f and .fd. The warp destinations into the (fingerprint) space are given by preceding each new instruction by the w(arp) suffix. A thread exiting a wormhole has its delta set to [1,0,...0]. If the top element of the stack is a set of data, it is popped and the current data is set to it. Execution proceeds normally until the Wrpc instruction is reached, at which point the set of data is push onto the stack and the thread is warped back to its previous space, its location and delta are restored. If the data is not pushed (wrpd), that instance will be lost (deallocated). The constructor is not called again for Wrpc as it is the same instance of data. The destructor is called in the case of Wrpd. At the time of the warp to a fingerprint, if the TOS is not a set of data, a default set of data is created, then the constructor is called. The constructor always exists and starts at location[0,...0]. The constructor should return using Wrpc, not Wrpd or an infinite loop may be entered. wDES, if it exists is called whenever an instance is lost
Table I | |
Letter | Meaning |
f | File |
c | Condition (II) |
d | Delta change (IV) |
p | Position change (V) |
i | Information about system (XIIV) |
m | Math (VI) |
u | User interaction (I/O) (VII) |
s | Space manipulation (XII) |
w | Warp in (for fps) (XIV) |
Table II: Conditions (letters two, three and four) | |
Letters | Meaning |
Table III | File |
P | abs Position change |
B | Bool check |
G | Greater than check |
E | Equality |
S | Smaller than check |
Table IIV: Delta changes (one letter) for II | |
Letters | Meaning |
L | Left turn |
R | Right turn |
^ | North |
> | East |
v | South |
< | West |
D | absolute Delta (pops new delta from stack) |
Z | No change |
R | Reflect |
B, G, E, S cannot be in any position but the first for this list (CG>< is permitted, but CDBZ is not). The default check is an inequality check.
Table IV: Delta Change | |
Letters | Meaning |
LFT (->^) | Left Turn |
RTT (->v) | Right Turn |
NTH (^^^) | North [0,-1,0,...0] |
EST (>>>) | East [1,0,...0] |
STH (vvv) | South [0,1,0,...0] |
WST (<<<) | West [-1,0,...0] |
RFL | Reflect |
ABS | Reflect |
RND (???) | Random redirection in any of the 3D-1 directions. |
ZZZ | No change |
Table IV follows directly from the D prefix on table I.
Table V: Position Change | |
Letters | Meaning |
ABS | Absolute position (pops vector off stack |
JPN | pops n, increments position n times |
JP? | unknown jump. Increments until the next PJP? is hit. |
JP# | Trampoline, skips next instruction |
Table V follows directly from the P prefix on table I.
Table VI: Math | |
Letters | Meaning |
add | |
sub | |
mul | |
div | |
gre | |
les | |
equ | |
flr | floor |
cel | ceil |
Table VI follows directly from the M prefix on table I.
Table VII: User interface | |
Letter | Meaning |
I | Input (IIX) |
O | Output (IX) |
M | Misc. (XI) |
Table VII follows directly from the U prefix on table I.
Table IIX: Input | |
Letter | Meaning |
P | Print to Screen (IX) |
Table IX: Output | |
Letter | Meaning |
K | Keyboard (IX) |
Tables IIX and IX follow from table VII.
Table X: Input/Output | |
Letter | Meaning |
C | Character |
N | Number |
S | String |
Table X follows from prefixes P and K on tables IIX and IX respectively.
Table XI: Misc user interface | |
Letters | Meaning |
MC | Move Cursor |
BC | change Background Colour |
FC | change Foreground Colour |
Table XI follows from prefix M on table VII.
Table XII: Space manipulation | |
Letter | Meaning |
get | pops vector, pushes cell at that position to stack |
put | pops vector, pops cell, places it at that position |
cpy | pops Vb, then Va, then Vc. copies cells in rect Va Vb to Vc (Vc+Vb) |
mov | Sim to copy, leaves noop. |
put | pops vector, pops cell, places it at that position |
put | pops vector, pops cell, places it at that position |
put | pops vector, pops cell, places it at that position |
Table XII follows directly from prefix S on table I.
Table XIIV: Information about the system | |
Letters | Meaning |
arg | pops n, pushes 0gnirts of that cmd line arg |
agn | pushes number of cmd line args |
psp | Path SeParator |
dlt | pushes delta |
pos | pushes position |
tid | thread id (no use yet until T) |
Table XIIV (XIII) follows directly from the prefix I on table I.
Table XIV: Warp | |
Letters | Meaning |
crd | Change Returning Delta, pops vector |
crp | Change Returning Position, pops vector, relative change |
rpc | Return to Previous space, copy data back to stack |
rpd | Return to Previous Space, instance Destroyed |
dat | pops Va, Vb, that rect is designated data for this instance |
cod | pops Va, Vb, that rect is designated code for this instance |
num | warp to to turn data into number (else 0) |
chr | warp to to turn data into character (else 0) |
DES | DEStructor, called for rpd |