version 1.6, 1997/08/02 20:19:21
|
version 1.7, 1997/08/03 20:21:54
|
Line 764 then in @file{~}, then in the normal pat
|
Line 764 then in @file{~}, then in the normal pat
|
* Blocks:: |
* Blocks:: |
* Other I/O:: |
* Other I/O:: |
* Programming Tools:: |
* Programming Tools:: |
* Assembler and Code words:: |
* Assembler and Code Words:: |
* Threading Words:: |
* Threading Words:: |
* Including Files:: |
* Including Files:: |
@end menu |
@end menu |
Line 3759 doc-to-this
|
Line 3759 doc-to-this
|
doc-xt-new |
doc-xt-new |
|
|
@c ------------------------------------------------------------- |
@c ------------------------------------------------------------- |
@node Object Oriented Forth, Objects, Tokens for Words, Words |
@node Object Oriented Forth, Tokens for Words, Objects, Words |
@section Object oriented Forth |
@section Object oriented Forth |
@cindex oof |
@cindex oof |
@cindex object-oriented programming |
@cindex object-oriented programming |
Line 3770 Gforth comes with two packets for object
|
Line 3770 Gforth comes with two packets for object
|
@file{objects.fs} and @file{oof.fs}; none of them is preloaded, so you |
@file{objects.fs} and @file{oof.fs}; none of them is preloaded, so you |
have to @code{include} them before use. This section describes the |
have to @code{include} them before use. This section describes the |
@file{oof.fs} packet. Both packets are written in ANS Forth and can be |
@file{oof.fs} packet. Both packets are written in ANS Forth and can be |
used with any other standard Forth (@exref{Objects}). This section uses |
used with any other standard Forth (@pxref{Objects}). This section uses |
the same rationale why using object-oriented programming, and the same |
the same rationale why using object-oriented programming, and the same |
terminology. |
terminology. |
|
|
Line 3782 create new medicaments, and a graphic us
|
Line 3782 create new medicaments, and a graphic us
|
* Properties of the OOF model:: |
* Properties of the OOF model:: |
* Basic OOF Usage:: |
* Basic OOF Usage:: |
* The base class object:: |
* The base class object:: |
|
* Class Declaration:: |
|
* Class Implementation:: |
@end menu |
@end menu |
|
|
@node Properties of the OOF model, Object Oriented Forth, Basic OOF Usage, Object Oriented Forth |
@node Properties of the OOF model, Basic OOF Usage, Object Oriented Forth, Object Oriented Forth |
@subsection Properties of the OOF model |
@subsection Properties of the OOF model |
@cindex @file{oof.fs} properties |
@cindex @file{oof.fs} properties |
|
|
Line 3817 An implementation in ANS Forth is availa
|
Line 3819 An implementation in ANS Forth is availa
|
@end itemize |
@end itemize |
|
|
|
|
@node Basic OOF Usage, Properties of the OOF model, The base class object, Object Oriented Forth |
@node Basic OOF Usage, The base class object, Properties of the OOF model, Object Oriented Forth |
@subsection Basic OOF Usage |
@subsection Basic OOF Usage |
@cindex @file{oof.fs} usage |
@cindex @file{oof.fs} usage |
|
|
Line 3893 Note: You can invoke a selector only if
|
Line 3895 Note: You can invoke a selector only if
|
the class where the selector was defined or one of its descendents; |
the class where the selector was defined or one of its descendents; |
e.g., you can invoke @code{draw} only for objects belonging to |
e.g., you can invoke @code{draw} only for objects belonging to |
@code{graphical} or its descendents (e.g., @code{circle}). The scoping |
@code{graphical} or its descendents (e.g., @code{circle}). The scoping |
mechanism will check if you try to invocate a selector that is not |
mechanism will check if you try to invoke a selector that is not |
defined in this class hierarchy, so you'll get an error at compilation |
defined in this class hierarchy, so you'll get an error at compilation |
time. |
time. |
|
|
|
|
@node The base class object, Basic OOF Usage, Tokes for Words, Object Oriented Forth |
@node The base class object, Class Declaration, Basic OOF Usage, Object Oriented Forth |
@subsection The base class @file{object} |
@subsection The base class @file{object} |
@cindex @file{oof.fs} base class |
@cindex @file{oof.fs} base class |
|
|
Line 3917 selectors of the class @code{object}.
|
Line 3919 selectors of the class @code{object}.
|
@code{class} for subclassing, @code{definitions} to add definitions |
@code{class} for subclassing, @code{definitions} to add definitions |
later on, and @code{class?} to get type informations (is the class a |
later on, and @code{class?} to get type informations (is the class a |
subclass of the class passed on the stack?). |
subclass of the class passed on the stack?). |
|
doc---object-class |
|
doc---object-definitions |
|
doc---object-class? |
|
|
@item |
@item |
@code{init} and @code{dispose} as constructor and destroctor of the |
@code{init} and @code{dispose} as constructor and destroctor of the |
Line 3924 object. @code{init} is invocated after t
|
Line 3929 object. @code{init} is invocated after t
|
while @code{dispose} also handles deallocation. Thus if you redefine |
while @code{dispose} also handles deallocation. Thus if you redefine |
@code{dispose}, you have to call the parent's dispose with @code{super |
@code{dispose}, you have to call the parent's dispose with @code{super |
dispose}, too. |
dispose}, too. |
|
doc---object-init |
|
doc---object-dispose |
|
|
@item |
@item |
@code{new}, @code{new[]}, @code{:}, @code{ptr}, and @code{[]} to create |
@code{new}, @code{new[]}, @code{:}, @code{ptr}, @code{asptr}, and |
named and unnamed objects and object arrays or object pointers. |
@code{[]} to create named and unnamed objects and object arrays or |
|
object pointers. |
|
doc---object-new |
|
doc---object-new[] |
|
doc---object-: |
|
doc---object-ptr |
|
doc---object-asptr |
|
doc---object-[] |
|
|
@item |
@item |
@code{::} and @code{super} for expicit scoping. You should use expicit |
@code{::} and @code{super} for expicit scoping. You should use expicit |
scoping only for super classes or classes with the same set of instance |
scoping only for super classes or classes with the same set of instance |
variables. Explicit scoped selectors use early binding. |
variables. Explicit scoped selectors use early binding. |
|
doc---object-:: |
|
doc---object-super |
|
|
@item |
@item |
@code{self} to get the address of the object |
@code{self} to get the address of the object |
|
doc---object-self |
|
|
@item |
@item |
@code{bind}, @code{bound}, @code{link}, and @code{is} to assign object |
@code{bind}, @code{bound}, @code{link}, and @code{is} to assign object |
pointers and instance defers. |
pointers and instance defers. |
|
doc---object-bind |
|
doc---object-bound |
|
doc---object-link |
|
doc---object-is |
|
|
@item |
@item |
@code{'} to obtain selector tokens, @code{send} to invocate selectors |
@code{'} to obtain selector tokens, @code{send} to invocate selectors |
form the stack, and @code{postpone} to generate selector invocation code. |
form the stack, and @code{postpone} to generate selector invocation code. |
|
doc---object-' |
|
doc---object-postpone |
|
|
@item |
@item |
@code{with} and @code{endwith} to select the active object from the |
@code{with} and @code{endwith} to select the active object from the |
stack, and enabling it's scope. Using @code{with} and @code{endwith} |
stack, and enabling it's scope. Using @code{with} and @code{endwith} |
also allows to create code using selector @code{postpone} without being |
also allows to create code using selector @code{postpone} without being |
trapped bye the state-smart objects. |
trapped bye the state-smart objects. |
|
doc---object-with |
|
doc---object-endwith |
|
|
@end itemize |
@end itemize |
|
|
|
@node Class Declaration, Class Implementation, The base class object, Object Oriented Forth |
|
@subsection Class Declaration |
|
@cindex class declaration |
|
|
|
@itemize @bullet |
|
@item |
|
Instance variables |
|
doc---oof-var |
|
|
|
@item |
|
Object pointers |
|
doc---oof-ptr |
|
doc---oof-asptr |
|
|
|
@item |
|
Instance defers |
|
doc---oof-defer |
|
|
|
@item |
|
Method selectors |
|
doc---oof-early |
|
doc---oof-method |
|
|
|
@item |
|
Class wide variables |
|
doc---oof-static |
|
|
|
@item |
|
End declaration |
|
doc---oof-how: |
|
doc---oof-class; |
|
|
|
@end itemize |
|
|
|
@node Class Implementation, , Class Declaration, Object Oriented Forth |
|
@subsection Class Implementation |
|
@cindex class implementation |
|
|
@c ------------------------------------------------------------- |
@c ------------------------------------------------------------- |
@node Tokens for Words, Wordlists, Object Oriented Forth, Words |
@node Tokens for Words, Wordlists, Object Oriented Forth, Words |
@section Tokens for Words |
@section Tokens for Words |
Line 4041 doc-name>string
|
Line 4104 doc-name>string
|
@node Other I/O, Programming Tools, Blocks, Words |
@node Other I/O, Programming Tools, Blocks, Words |
@section Other I/O |
@section Other I/O |
|
|
@node Programming Tools, Assembler and Code words, Other I/O, Words |
@node Programming Tools, Assembler and Code Words, Other I/O, Words |
@section Programming Tools |
@section Programming Tools |
@cindex programming tools |
@cindex programming tools |
|
|
Line 4212 program has stopped at the moment. You c
|
Line 4275 program has stopped at the moment. You c
|
@code{BREAK" string"} command. This behaves like @code{BREAK:} except that |
@code{BREAK" string"} command. This behaves like @code{BREAK:} except that |
string is typed out when the ``breakpoint'' is reached. |
string is typed out when the ``breakpoint'' is reached. |
|
|
@node Assembler and Code words, Threading Words, Programming Tools, Words |
@node Assembler and Code Words, Threading Words, Programming Tools, Words |
@section Assembler and Code words |
@section Assembler and Code Words |
@cindex assembler |
@cindex assembler |
@cindex code words |
@cindex code words |
|
|
Line 4320 with @code{>DOES-CODE}. If the word was
|
Line 4383 with @code{>DOES-CODE}. If the word was
|
returned is different from 0 and identifies the @code{DOES>} used by the |
returned is different from 0 and identifies the @code{DOES>} used by the |
defining word. |
defining word. |
|
|
@node Including Files, , Threading Words, Words |
@node Including Files, Include and Require, Threading Words, Words |
@section Including Files |
@section Including Files |
@cindex including files |
@cindex including files |
|
|
@node Include and Require, Path handling, Including Files, Words |
@menu |
|
* Include and Require:: |
|
* Path Handling:: |
|
@end menu |
|
|
|
@node Include and Require, Path Handling, Including Files, Including Files |
@subsection Include and Requrie |
@subsection Include and Requrie |
|
|
There a two words to include the source files more intelligently. |
There a two words to include the source files more intelligently. |
Line 4332 There a two words to include the source
|
Line 4400 There a two words to include the source
|
doc-include |
doc-include |
doc-require |
doc-require |
|
|
@node Path handling, ,Require, Words |
@node Path Handling, , Include and Require, Including Files |
@subsection Path handling |
@subsection Path Handling |
@cindex path handling |
@cindex path handling |
|
|
In larger program projects it is often neccassary to build up a structured |
In larger program projects it is often neccassary to build up a structured |