Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,8 +1,8 @@
|
|||
#define system.
|
||||
#define extensions.
|
||||
|
||||
#class Extender
|
||||
#class Extender :: BaseExtender
|
||||
{
|
||||
#field theObject.
|
||||
#field theField.
|
||||
|
||||
#constructor new : anObject
|
||||
|
|
@ -16,20 +16,18 @@
|
|||
[
|
||||
theField := aValue.
|
||||
]
|
||||
|
||||
#method => theObject.
|
||||
}
|
||||
|
||||
#symbol program =
|
||||
[
|
||||
#var anObject := 234.
|
||||
|
||||
// adding a field
|
||||
// extending an object with a field
|
||||
anObject := Extender new:anObject.
|
||||
|
||||
anObject set &foo:"bar".
|
||||
|
||||
console << anObject << ".foo=" << anObject foo.
|
||||
console writeLine:anObject:".foo=":(anObject foo).
|
||||
|
||||
console readChar.
|
||||
].
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
include FMS-SI.f
|
||||
include FMS-SILib.f
|
||||
|
||||
|
||||
\ FMS doesn't have the ability to add instance variables
|
||||
\ or methods at run time. But it is very simple to add any number of
|
||||
\ objects of any type to a single object at run time. The added
|
||||
\ objects are then accessible via an index number.
|
||||
|
||||
:class foo
|
||||
object-list inst-objects \ a dynamically growable object container
|
||||
:m add: ( obj -- ) inst-objects add: ;m
|
||||
:m at: ( idx -- obj ) inst-objects at: ;m
|
||||
;class
|
||||
|
||||
foo foo1
|
||||
|
||||
: main
|
||||
heap> string foo1 add:
|
||||
heap> fvar foo1 add:
|
||||
|
||||
s" Now is the time " 0 foo1 at: !:
|
||||
3.14159e 1 foo1 at: !:
|
||||
|
||||
0 foo1 at: p: \ send the print message to indexed object 0
|
||||
1 foo1 at: p: \ send the print message to indexed object 1
|
||||
;
|
||||
|
||||
main \ => Now is the time 3.14159
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
use MONKEY_TYPING;
|
||||
use MONKEY-TYPING;
|
||||
augment class Int {
|
||||
method answer { "Life, the Universe, and Everything" }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue