@@ -7728,7 +7728,7 @@ doc-get-order
7728
7728
doc---gforthman-set-order
7729
7729
doc-wordlist
7730
7730
doc-table
7731
- doc-push- order
7731
+ doc-> order
7732
7732
doc-previous
7733
7733
doc-also
7734
7734
doc---gforthman-forth
@@ -7982,7 +7982,7 @@ set-current
7982
7982
You can see what definitions are in the environment word list like this:
7983
7983
7984
7984
@example
7985
- environment-wordlist push- order words previous
7985
+ environment-wordlist > order words previous
7986
7986
@end example
7987
7987
7988
7988
@@ -10400,12 +10400,13 @@ doc---objects-class
10400
10400
doc---objects-class->map
10401
10401
doc---objects-class-inst-size
10402
10402
doc---objects-class-override!
10403
+ doc---objects-class-previous
10404
+ doc---objects-class>order
10403
10405
doc---objects-construct
10404
10406
doc---objects-current'
10405
10407
doc---objects-[current]
10406
10408
doc---objects-current-interface
10407
10409
doc---objects-dict-new
10408
- doc---objects-drop-order
10409
10410
doc---objects-end-class
10410
10411
doc---objects-end-class-noname
10411
10412
doc---objects-end-interface
@@ -10429,8 +10430,6 @@ doc---objects-[parent]
10429
10430
doc---objects-print
10430
10431
doc---objects-protected
10431
10432
doc---objects-public
10432
- @c !! push-order conflicts
10433
- doc---objects-push-order
10434
10433
doc---objects-selector
10435
10434
doc---objects-this
10436
10435
doc---objects-<to-inst>
@@ -10733,7 +10732,7 @@ doc---oof-class;
10733
10732
@cindex mini-oof
10734
10733
10735
10734
Gforth's third object oriented Forth package is a 12-liner. It uses a
10736
- mixture of the @file{object .fs} and the @file{oof.fs} syntax,
10735
+ mixture of the @file{objects .fs} and the @file{oof.fs} syntax,
10737
10736
and reduces to the bare minimum of features. This is based on a posting
10738
10737
of Bernd Paysan in comp.lang.forth.
10739
10738
@@ -10839,25 +10838,26 @@ Object-oriented systems with late binding typically use a
10839
10838
table, which contains the methods as function pointers. The vtable
10840
10839
may also contain other information.
10841
10840
10842
- So first, let's declare methods :
10841
+ So first, let's declare selectors :
10843
10842
10844
10843
@example
10845
- : method ( m v -- m' v ) Create over , swap cell+ swap
10844
+ : method ( m v "name" -- m' v ) Create over , swap cell+ swap
10846
10845
DOES> ( ... o -- ... ) @@ over @@ + @@ execute ;
10847
10846
@end example
10848
10847
10849
- During method declaration, the number of methods and instance
10850
- variables is on the stack (in address units). @code{method} creates
10851
- one method and increments the method number. To execute a method , it
10848
+ During selector declaration, the number of selectors and instance
10849
+ variables is on the stack (in address units). @code{method} creates one
10850
+ selector and increments the selector number. To execute a selector , it
10852
10851
takes the object, fetches the vtable pointer, adds the offset, and
10853
- executes the @i{xt} stored there. Each method takes the object it is
10854
- invoked from as top of stack parameter. The method itself should
10852
+ executes the method @i{xt} stored there. Each selector takes the object
10853
+ it is invoked with as top of stack parameter; it passes the parameters
10854
+ (including the object) unchanged to the appropriate method which should
10855
10855
consume that object.
10856
10856
10857
10857
Now, we also have to declare instance variables
10858
10858
10859
10859
@example
10860
- : var ( m v size -- m v' ) Create over , +
10860
+ : var ( m v size "name" -- m v' ) Create over , +
10861
10861
DOES> ( o -- addr ) @@ + ;
10862
10862
@end example
10863
10863
@@ -10872,15 +10872,15 @@ We need a starting point (the base object) and some syntactic sugar:
10872
10872
10873
10873
@example
10874
10874
Create object 1 cells , 2 cells ,
10875
- : class ( class -- class methods vars ) dup 2@@ ;
10875
+ : class ( class -- class selectors vars ) dup 2@@ ;
10876
10876
@end example
10877
10877
10878
10878
For inheritance, the vtable of the parent object has to be
10879
10879
copied when a new, derived class is declared. This gives all the
10880
10880
methods of the parent class, which can be overridden, though.
10881
10881
10882
10882
@example
10883
- : end-class ( class methods vars -- )
10883
+ : end-class ( class selectors vars "name" -- )
10884
10884
Create here >r , dup , 2 cells ?DO ['] noop , 1 cells +LOOP
10885
10885
cell+ dup cell+ r> rot @@ 2 cells /string move ;
10886
10886
@end example
@@ -10892,7 +10892,7 @@ copies the xts from the parent vtable.
10892
10892
We still have no way to define new methods, let's do that now:
10893
10893
10894
10894
@example
10895
- : defines ( xt class -- ) ' >body @@ + ! ;
10895
+ : defines ( xt class "name" -- ) ' >body @@ + ! ;
10896
10896
@end example
10897
10897
10898
10898
To allocate a new object, we need a word, too:
@@ -10940,7 +10940,7 @@ Now, implement the two methods, @code{draw} and @code{init}:
10940
10940
10941
10941
@noindent
10942
10942
To demonstrate inheritance, we define a class @code{bold-button}, with no
10943
- new data and no new methods :
10943
+ new data and no new selectors :
10944
10944
10945
10945
@example
10946
10946
button class
@@ -10960,7 +10960,7 @@ for @code{button}:
10960
10960
@end example
10961
10961
10962
10962
@noindent
10963
- Finally, create two objects and apply methods :
10963
+ Finally, create two objects and apply selectors :
10964
10964
10965
10965
@example
10966
10966
button new Constant foo
@@ -11001,13 +11001,13 @@ to pass objects on the stack.
11001
11001
11002
11002
@item
11003
11003
It requires that the selector parses the input stream (at
11004
- compile time); this leads to reduced extensibility and to bugs that are+
11004
+ compile time); this leads to reduced extensibility and to bugs that are
11005
11005
hard to find.
11006
11006
11007
11007
@item
11008
- It allows using every selector to every object;
11009
- this eliminates the need for classes , but makes it harder to create
11010
- efficient implementations.
11008
+ It allows using every selector on every object; this eliminates the
11009
+ need for interfaces , but makes it harder to create efficient
11010
+ implementations.
11011
11011
@end itemize
11012
11012
11013
11013
@cindex Pountain's object-oriented model
@@ -11018,19 +11018,20 @@ binding. Instead, it focuses on features like information hiding and
11018
11018
overloading that are characteristic of modular languages like Ada (83).
11019
11019
11020
11020
@cindex Zsoter's object-oriented model
11021
- In @cite{Does late binding have to be slow?} (Forth Dimensions 18(1)
11022
- 1996, pages 31-35) Andras Zsoter describes a model that makes heavy use
11023
- of an active object (like @code{this} in @file{objects.fs}): The active
11024
- object is not only used for accessing all fields, but also specifies the
11025
- receiving object of every selector invocation; you have to change the
11026
- active object explicitly with @code{@{ ... @}}, whereas in
11027
- @file{objects.fs} it changes more or less implicitly at @code{m:
11028
- ... ;m}. Such a change at the method entry point is unnecessary with the
11029
- Zsoter's model, because the receiving object is the active object
11030
- already. On the other hand, the explicit change is absolutely necessary
11031
- in that model, because otherwise no one could ever change the active
11032
- object. An ANS Forth implementation of this model is available at
11033
- @uref{http://www.forth.org/fig/oopf.html}.
11021
+ In @uref{http://www.forth.org/oopf.html, Does late binding have to be
11022
+ slow?} (Forth Dimensions 18(1) 1996, pages 31-35) Andras Zsoter
11023
+ describes a model that makes heavy use of an active object (like
11024
+ @code{this} in @file{objects.fs}): The active object is not only used
11025
+ for accessing all fields, but also specifies the receiving object of
11026
+ every selector invocation; you have to change the active object
11027
+ explicitly with @code{@{ ... @}}, whereas in @file{objects.fs} it
11028
+ changes more or less implicitly at @code{m: ... ;m}. Such a change at
11029
+ the method entry point is unnecessary with Zsoter's model, because the
11030
+ receiving object is the active object already. On the other hand, the
11031
+ explicit change is absolutely necessary in that model, because otherwise
11032
+ no one could ever change the active object. An ANS Forth implementation
11033
+ of this model is available through
11034
+ @uref{http://www.forth.org/oopf.html}.
11034
11035
11035
11036
@cindex @file{oof.fs}, differences to other models
11036
11037
The @file{oof.fs} model combines information hiding and overloading
@@ -11768,12 +11769,10 @@ doc-getenv
11768
11769
@section Keeping track of Time
11769
11770
@cindex time-related words
11770
11771
11771
- Gforth implements time-related operations by making calls to the C
11772
- library function, @code{gettimeofday}.
11773
-
11774
11772
doc-ms
11775
11773
doc-time&date
11776
-
11774
+ doc-utime
11775
+ doc-cputime
11777
11776
11778
11777
11779
11778
@c -------------------------------------------------------------
@@ -11810,6 +11809,7 @@ in file included from ./yyy.fs:1
11810
11809
./xxx.fs:4: Invalid memory address
11811
11810
bar
11812
11811
^^^
11812
+ Backtrace:
11813
11813
$400E664C @@
11814
11814
$400E6664 foo
11815
11815
@end example
@@ -11857,7 +11857,7 @@ case.
11857
11857
@cindex @code{gforth-fast}, difference from @code{gforth}
11858
11858
@cindex backtraces with @code{gforth-fast}
11859
11859
@cindex return stack dump with @code{gforth-fast}
11860
- @code{gforth } is able to do a return stack dump for throws generated
11860
+ @code{Gforth } is able to do a return stack dump for throws generated
11861
11861
from primitives (e.g., invalid memory address, stack empty etc.);
11862
11862
@code{gforth-fast} is only able to do a return stack dump from a
11863
11863
directly called @code{throw} (including @code{abort} etc.). This is the
@@ -12067,7 +12067,7 @@ If @code{WORD} is called with the space character as a delimiter, all
12067
12067
white-space characters (as identified by the C macro @code{isspace()})
12068
12068
are delimiters. @code{PARSE}, on the other hand, treats space like other
12069
12069
delimiters. @code{SWORD} treats space like @code{WORD}, but behaves
12070
- like @code{PARSE} otherwise. @code{(NAME) }, which is used by the outer
12070
+ like @code{PARSE} otherwise. @code{Name }, which is used by the outer
12071
12071
interpreter (aka text interpreter) by default, treats all white-space
12072
12072
characters as delimiters.
12073
12073
@@ -12110,7 +12110,7 @@ lines. One of these characters is typically produced when you type the
12110
12110
@cindex maximum size of a counted string
12111
12111
@cindex counted string, maximum size
12112
12112
@code{s" /counted-string" environment? drop .}. Currently 255 characters
12113
- on all ports , but this may change.
12113
+ on all platforms , but this may change.
12114
12114
12115
12115
@item maximum size of a parsed string:
12116
12116
@cindex maximum size of a parsed string
@@ -12147,11 +12147,11 @@ What are we expected to document here?
12147
12147
@cindex number of bits in one address unit
12148
12148
@cindex address unit, size in bits
12149
12149
@code{s" address-units-bits" environment? drop .}. 8 in all current
12150
- ports .
12150
+ platforms .
12151
12151
12152
12152
@item number representation and arithmetic:
12153
12153
@cindex number representation and arithmetic
12154
- Processor-dependent. Binary two's complement on all current ports .
12154
+ Processor-dependent. Binary two's complement on all current platforms .
12155
12155
12156
12156
@item ranges for integer types:
12157
12157
@cindex ranges for integer types
@@ -12182,7 +12182,7 @@ string.
12182
12182
12183
12183
@item size of one character in address units:
12184
12184
@cindex char size
12185
- @code{1 chars .}. 1 on all current ports .
12185
+ @code{1 chars .}. 1 on all current platforms .
12186
12186
12187
12187
@item size of the keyboard terminal buffer:
12188
12188
@cindex size of the keyboard terminal buffer
0 commit comments