5 - Forth Interest Group
5 - Forth Interest Group
5 - Forth Interest Group
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Figure Four. Words to create objects and instance variables. I I<br />
I \ oofob jec. fth 910730 rwb I<br />
: +objects \ ( 'body -- 'objects ) MACRO<br />
dup cell- @ \ ( -- 'body 'el-class )<br />
+/body @ + ;<br />
: /body \ ( -- /body )<br />
context @ +/body @ ;<br />
: do-object \ ( /body --<br />
allot<br />
does><br />
dup @ >context \ select object's context.<br />
cell+ \ ( -- 'body )<br />
: object \ ( -- ) Create instance of class.<br />
create context @ , /body do-object ;<br />
: objects \ ( n -- Create n instances of class.<br />
/body over \ ( -- n /body n )<br />
last @ name> >body cell+ \ ( -- n /body n 'body )<br />
context @ over cell+ \ ( -- n /body n '#el 'elclass "elclass )<br />
! ! \ ( -- n /body<br />
* do-object ;<br />
: do-var \ ( offset /body -- offset' )<br />
over , +<br />
does> ( pfa -- 'body )<br />
dup @ >context<br />
cell+ @ + \ ( -- 'var )<br />
,<br />
: :var \ ( offset -- offset' ) Create instance variable.<br />
create context @ , /body do-var ;<br />
: :vars \ ( offset n -- offset' ) Create n instance variables.<br />
/body over \ ( -- offset n /body n )<br />
last @ name> >body cell+ \ ( -- offset n /body n 'body )<br />
context @ over cell+ \ ( -- offset n /body n '#el 'elclas "elclass )<br />
! ! \ ( -- offset n /body )<br />
* do-var ;<br />
cr .( oofobjec.fth loaded ) cr<br />
Advertisers<br />
Index<br />
ACM ............................. 22<br />
Ciber ............................... 7<br />
<strong>Forth</strong> <strong>Interest</strong> <strong>Group</strong> ...... .44<br />
Harvard Softworks .......... 41<br />
Miller Microcomputer<br />
Services.. ................... .27<br />
Next Generation<br />
Systems ...................... 42<br />
Silicon Composers .......... .2<br />
<strong>Forth</strong> Dimensions 27 January 1992 February