1stooop(n)         Simple Tcl Only Object Oriented Programming        stooop(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       stooop - Object oriented extension.
9

SYNOPSIS

11       package require Tcl  8.3
12
13       package require stooop  ?4.4.1?
14
15       ::stooop::class name body
16
17       ::stooop::new class ?arg arg ...?
18
19       ::stooop::delete object ?object ...?
20
21       ::stooop::virtual proc name {this ?arg arg ...?} ?body?
22
23       ::stooop::classof object
24
25       ::stooop::new object
26
27       ::stooop::printObjects ?pattern?
28
29       ::stooop::record
30
31       ::stooop::report ?pattern?
32
33______________________________________________________________________________
34

DESCRIPTION

36       This package provides commands to extend Tcl in an object oriented man‐
37       ner, using a familiar C++ like syntax and behaviour. Stooop only intro‐
38       duces  a  few  new  commands:  class, new, delete, virtual and classof.
39       Along with a few coding conventions, that is basically all you need  to
40       know to use stooop. Stooop is meant to be as simple to use as possible.
41
42       This  manual is very succinct and is to be used as a quick reminder for
43       the programmer, who should have read the thorough stooop_man.html  HTML
44       documentation at this point.
45
46       ::stooop::class name body
47              This command creates a class. The body, similar in contents to a
48              Tcl namespace (which a class actually also is), contains  member
49              procedure  definitions.  Member  procedures  can also be defined
50              outside the class body, by prefixing their name with class::, as
51              you would proceed with namespace procedures.
52
53              proc class {this ?arg arg ...?} ?base {?arg arg ...?} ...? body
54                     This  is  the  constructor procedure for the class. It is
55                     invoked following a new invocation on the class. It  must
56                     have  the  same  name  as  the class and a first argument
57                     named this. Any number of  base  classes  specifications,
58                     including  arguments  to  be passed to their constructor,
59                     are allowed before the actual body of the procedure.
60
61              proc ~class {this} body
62                     This is the destructor procedure for  the  class.  It  is
63                     invoked  following  a delete invocation. Its name must be
64                     the concatenation of a single ~ character followed by the
65                     class  name  (as  in C++). It must have a single argument
66                     named this.
67
68              proc name {this ?arg arg ...?} body
69                     This is a member procedure of the  class,  as  its  first
70                     argument is named this. It allows a simple access of mem‐
71                     ber data for the object referenced  by  this  inside  the
72                     procedure. For example:
73
74
75                        set ($this,data) 0
76
77
78              proc name {?arg arg ...?} body
79                     This  is  a  static  (as  in C++) member procedure of the
80                     class, as its first argument is not  named  this.  Static
81                     (global) class data can be accessed as in:
82
83
84                        set (data) 0
85
86
87              proc class {this copy} body
88                     This  is  the  optional  copy procedure for the class. It
89                     must have the same name as the class and exactly 2  argu‐
90                     ments  named this and copy. It is invoked following a new
91                     invocation on an existing object of the class.
92
93       ::stooop::new class ?arg arg ...?
94              This command is used to create an object. The first argument  is
95              the  class  name  and is followed by the arguments needed by the
96              corresponding class constructor. A  unique  identifier  for  the
97              object just created is returned.
98
99       ::stooop::delete object ?object ...?
100              This  command is used to delete one or several objects. It takes
101              one or more object identifiers as argument(s).
102
103       ::stooop::virtual proc name {this ?arg arg ...?} ?body?
104              The virtual specifier  may  be  used  on  member  procedures  to
105              achieve dynamic binding. A procedure in a base class can then be
106              redefined (overloaded) in the derived  class(es).  If  the  base
107              class  procedure  is  invoked  on  an object, it is actually the
108              derived class procedure which is invoked, if it exists.  If  the
109              base  class procedure has no body, then it is considered to be a
110              pure virtual and the derived class procedure is always invoked.
111
112       ::stooop::classof object
113              This command returns the class of the existing object passed  as
114              single parameter.
115
116       ::stooop::new object
117              This  command is used to create an object by copying an existing
118              object. The copy  constructor  of  the  corresponding  class  is
119              invoked  if  it  exists,  otherwise  a simple copy of the copied
120              object data members is performed.
121

DEBUGGING

123       Environment variables
124
125              STOOOPCHECKDATA
126                     Setting this variable to any true value will cause stooop
127                     to check for invalid member or class data access.
128
129              STOOOPCHECKPROCEDURES
130                     Setting this variable to any true value will cause stooop
131                     to check for invalid member procedure arguments and  pure
132                     interface classes instanciation.
133
134              STOOOPCHECKALL
135                     Setting this variable to any true value will cause stooop
136                     to activate both procedure and data member checking.
137
138              STOOOPCHECKOBJECTS
139                     Setting this variable to any true value will cause stooop
140                     to  activate object checking. The following stooop names‐
141                     pace procedures  then  become  available  for  debugging:
142                     printObjects, record and report.
143
144              STOOOPTRACEPROCEDURES
145                     Setting  this  environment  variable  to  either  stdout,
146                     stderr or a file name, activates procedure  tracing.  The
147                     stooop  library will then output to the specified channel
148                     1 line of informational text for  each  member  procedure
149                     invocation.
150
151              STOOOPTRACEPROCEDURESFORMAT
152                     Defines  the  trace procedures output format. Defaults to
153                     "class: %C, procedure: %p, object: %O, arguments: %a".
154
155              STOOOPTRACEDATA
156                     Setting  this  environment  variable  to  either  stdout,
157                     stderr or a file name, activates data tracing. The stooop
158                     library will then output to the specified channel 1  line
159                     of informational text for each member data access.
160
161              STOOOPTRACEDATAFORMAT
162                     Defines the trace data output format. Defaults to "class:
163                     %C, procedure: %p, array: %A,  object:  %O,  member:  %m,
164                     operation: %o, value: %v".
165
166              STOOOPTRACEDATAOPERATIONS
167                     When tracing data output, by default, all read, write and
168                     unsetting accesses are reported, but  the  user  can  set
169                     this variable to any combination of the letters r, w, and
170                     u for more specific tracing (please refer  to  the  trace
171                     Tcl manual page for more information).
172
173              STOOOPTRACEALL
174                     Setting  this  environment  variable  to  either  stdout,
175                     stderr or a file name, enables both  procedure  and  data
176                     tracing.
177
178       ::stooop::printObjects ?pattern?
179              Prints  an  ordered list of existing objects, in creation order,
180              oldest first. Each output line contains the class  name,  object
181              identifier and the procedure within which the creation occurred.
182              The optional pattern argument (as in the Tcl string  match  com‐
183              mand) can be used to limit the output to matching class names.
184
185       ::stooop::record
186              When  invoked,  a  snapshot  of  all  existing stooop objects is
187              taken. Reporting can then be used at a later time to  see  which
188              objects were created or deleted in the interval.
189
190       ::stooop::report ?pattern?
191              Prints    the    created   and   deleted   objects   since   the
192              ::stooop::record procedure was invoked  last.  If  present,  the
193              pattern argument limits the output to matching class names.
194

EXAMPLES

196       Please see the full HTML documentation in stooop_man.html.
197

BUGS, IDEAS, FEEDBACK

199       This  document,  and the package it describes, will undoubtedly contain
200       bugs and other problems.  Please report such in the category stooop  of
201       the  Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please
202       also report any ideas for enhancements you may have for either  package
203       and/or documentation.
204
205       When proposing code changes, please provide unified diffs, i.e the out‐
206       put of diff -u.
207
208       Note further that  attachments  are  strongly  preferred  over  inlined
209       patches.  Attachments  can  be  made  by  going to the Edit form of the
210       ticket immediately after its creation, and  then  using  the  left-most
211       button in the secondary navigation bar.
212

KEYWORDS

214       C++, class, object, object oriented
215

CATEGORY

217       Programming tools
218
219
220
221tcllib                               4.4.1                           stooop(n)
Impressum