Skip to content

Commit 2bcf0d0

Browse files
author
anton
committed
Documentation changes
renamed general push-order to >order, objects push-order to class>order, drop-order to class-previous
1 parent 6c74cd6 commit 2bcf0d0

File tree

6 files changed

+325
-64
lines changed

6 files changed

+325
-64
lines changed

doc/gforth.ds

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7728,7 +7728,7 @@ doc-get-order
77287728
doc---gforthman-set-order
77297729
doc-wordlist
77307730
doc-table
7731-
doc-push-order
7731+
doc->order
77327732
doc-previous
77337733
doc-also
77347734
doc---gforthman-forth
@@ -7982,7 +7982,7 @@ set-current
79827982
You can see what definitions are in the environment word list like this:
79837983

79847984
@example
7985-
environment-wordlist push-order words previous
7985+
environment-wordlist >order words previous
79867986
@end example
79877987

79887988

@@ -10400,12 +10400,13 @@ doc---objects-class
1040010400
doc---objects-class->map
1040110401
doc---objects-class-inst-size
1040210402
doc---objects-class-override!
10403+
doc---objects-class-previous
10404+
doc---objects-class>order
1040310405
doc---objects-construct
1040410406
doc---objects-current'
1040510407
doc---objects-[current]
1040610408
doc---objects-current-interface
1040710409
doc---objects-dict-new
10408-
doc---objects-drop-order
1040910410
doc---objects-end-class
1041010411
doc---objects-end-class-noname
1041110412
doc---objects-end-interface
@@ -10429,8 +10430,6 @@ doc---objects-[parent]
1042910430
doc---objects-print
1043010431
doc---objects-protected
1043110432
doc---objects-public
10432-
@c !! push-order conflicts
10433-
doc---objects-push-order
1043410433
doc---objects-selector
1043510434
doc---objects-this
1043610435
doc---objects-<to-inst>
@@ -10733,7 +10732,7 @@ doc---oof-class;
1073310732
@cindex mini-oof
1073410733

1073510734
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,
1073710736
and reduces to the bare minimum of features. This is based on a posting
1073810737
of Bernd Paysan in comp.lang.forth.
1073910738

@@ -10839,25 +10838,26 @@ Object-oriented systems with late binding typically use a
1083910838
table, which contains the methods as function pointers. The vtable
1084010839
may also contain other information.
1084110840

10842-
So first, let's declare methods:
10841+
So first, let's declare selectors:
1084310842

1084410843
@example
10845-
: method ( m v -- m' v ) Create over , swap cell+ swap
10844+
: method ( m v "name" -- m' v ) Create over , swap cell+ swap
1084610845
DOES> ( ... o -- ... ) @@ over @@ + @@ execute ;
1084710846
@end example
1084810847

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
1085210851
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
1085510855
consume that object.
1085610856

1085710857
Now, we also have to declare instance variables
1085810858

1085910859
@example
10860-
: var ( m v size -- m v' ) Create over , +
10860+
: var ( m v size "name" -- m v' ) Create over , +
1086110861
DOES> ( o -- addr ) @@ + ;
1086210862
@end example
1086310863

@@ -10872,15 +10872,15 @@ We need a starting point (the base object) and some syntactic sugar:
1087210872

1087310873
@example
1087410874
Create object 1 cells , 2 cells ,
10875-
: class ( class -- class methods vars ) dup 2@@ ;
10875+
: class ( class -- class selectors vars ) dup 2@@ ;
1087610876
@end example
1087710877

1087810878
For inheritance, the vtable of the parent object has to be
1087910879
copied when a new, derived class is declared. This gives all the
1088010880
methods of the parent class, which can be overridden, though.
1088110881

1088210882
@example
10883-
: end-class ( class methods vars -- )
10883+
: end-class ( class selectors vars "name" -- )
1088410884
Create here >r , dup , 2 cells ?DO ['] noop , 1 cells +LOOP
1088510885
cell+ dup cell+ r> rot @@ 2 cells /string move ;
1088610886
@end example
@@ -10892,7 +10892,7 @@ copies the xts from the parent vtable.
1089210892
We still have no way to define new methods, let's do that now:
1089310893

1089410894
@example
10895-
: defines ( xt class -- ) ' >body @@ + ! ;
10895+
: defines ( xt class "name" -- ) ' >body @@ + ! ;
1089610896
@end example
1089710897

1089810898
To allocate a new object, we need a word, too:
@@ -10940,7 +10940,7 @@ Now, implement the two methods, @code{draw} and @code{init}:
1094010940

1094110941
@noindent
1094210942
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:
1094410944

1094510945
@example
1094610946
button class
@@ -10960,7 +10960,7 @@ for @code{button}:
1096010960
@end example
1096110961

1096210962
@noindent
10963-
Finally, create two objects and apply methods:
10963+
Finally, create two objects and apply selectors:
1096410964

1096510965
@example
1096610966
button new Constant foo
@@ -11001,13 +11001,13 @@ to pass objects on the stack.
1100111001

1100211002
@item
1100311003
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
1100511005
hard to find.
1100611006

1100711007
@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.
1101111011
@end itemize
1101211012

1101311013
@cindex Pountain's object-oriented model
@@ -11018,19 +11018,20 @@ binding. Instead, it focuses on features like information hiding and
1101811018
overloading that are characteristic of modular languages like Ada (83).
1101911019

1102011020
@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}.
1103411035

1103511036
@cindex @file{oof.fs}, differences to other models
1103611037
The @file{oof.fs} model combines information hiding and overloading
@@ -11768,12 +11769,10 @@ doc-getenv
1176811769
@section Keeping track of Time
1176911770
@cindex time-related words
1177011771

11771-
Gforth implements time-related operations by making calls to the C
11772-
library function, @code{gettimeofday}.
11773-
1177411772
doc-ms
1177511773
doc-time&date
11776-
11774+
doc-utime
11775+
doc-cputime
1177711776

1177811777

1177911778
@c -------------------------------------------------------------
@@ -11810,6 +11809,7 @@ in file included from ./yyy.fs:1
1181011809
./xxx.fs:4: Invalid memory address
1181111810
bar
1181211811
^^^
11812+
Backtrace:
1181311813
$400E664C @@
1181411814
$400E6664 foo
1181511815
@end example
@@ -11857,7 +11857,7 @@ case.
1185711857
@cindex @code{gforth-fast}, difference from @code{gforth}
1185811858
@cindex backtraces with @code{gforth-fast}
1185911859
@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
1186111861
from primitives (e.g., invalid memory address, stack empty etc.);
1186211862
@code{gforth-fast} is only able to do a return stack dump from a
1186311863
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
1206712067
white-space characters (as identified by the C macro @code{isspace()})
1206812068
are delimiters. @code{PARSE}, on the other hand, treats space like other
1206912069
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
1207112071
interpreter (aka text interpreter) by default, treats all white-space
1207212072
characters as delimiters.
1207312073

@@ -12110,7 +12110,7 @@ lines. One of these characters is typically produced when you type the
1211012110
@cindex maximum size of a counted string
1211112111
@cindex counted string, maximum size
1211212112
@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.
1211412114

1211512115
@item maximum size of a parsed string:
1211612116
@cindex maximum size of a parsed string
@@ -12147,11 +12147,11 @@ What are we expected to document here?
1214712147
@cindex number of bits in one address unit
1214812148
@cindex address unit, size in bits
1214912149
@code{s" address-units-bits" environment? drop .}. 8 in all current
12150-
ports.
12150+
platforms.
1215112151

1215212152
@item number representation and arithmetic:
1215312153
@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.
1215512155

1215612156
@item ranges for integer types:
1215712157
@cindex ranges for integer types
@@ -12182,7 +12182,7 @@ string.
1218212182

1218312183
@item size of one character in address units:
1218412184
@cindex char size
12185-
@code{1 chars .}. 1 on all current ports.
12185+
@code{1 chars .}. 1 on all current platforms.
1218612186

1218712187
@item size of the keyboard terminal buffer:
1218812188
@cindex size of the keyboard terminal buffer

0 commit comments

Comments
 (0)