Update.
[pspp-builds.git] / TODO
1 Time-stamp: <2003-12-15 22:51:49 blp>
2
3 TODO
4 ----
5
6 Use AFM files instead of Groff font files, and include AFMs for our default
7 fonts with the distribution.
8
9 The way that data-in.c and data-out.c deal with strings is wrong.  Instead of
10 the way it's done now, we should make it dynamically allocate a buffer and
11 return a pointer to it.  This is a much safer interface.
12
13 Add libplot output driver.  Suggested by Robert S. Maier
14 <rsm@math.arizona.edu>: "it produces output in idraw-editable PS format, PCL5
15 format, xfig-editable format, Illustrator format,..., and can draw vector
16 graphics on X11 displays also".
17
18 Storage of value labels on disk is inefficient.  Invent new data structure.
19
20 Add an output flag which would cause a page break if a table segment could fit
21 vertically on a page but it just happens to be positioned such that it won't.
22
23 Fix spanned joint cells, i.e., EDLEVEL on crosstabs.stat.
24
25 Cell footnotes.
26
27 PostScript driver should emit thin lines, then thick lines, to optimize time
28 and space.
29
30 New functions?  var_name_or_label(), tab_value_or_label()
31
32 Should be able to bottom-justify cells.  It'll be expensive, though, by
33 requiring an extra metrics call.
34
35 Perhaps instead of the current lines we should define the following line types:
36 null, thin, thick, double.  It might look pretty classy.
37
38 Perhaps thick table borders that are cut off by a page break should decay to
39 thin borders.  (i.e., on a thick bordered table that's longer than one page,
40 but narrow, the bottom border would be thin on the first page, and the top and
41 bottom borders on middle pages.)
42
43 Support multi-line titles on tables. (For the first page only, presumably.)
44
45 Rewrite the convert_F() function in data-out.c to be nicer code.
46
47 In addition to searching the source directory, we should search the current
48 directory (for data files).  (Yuck!)
49
50 Fix line-too-long problems in PostScript code, instead of covering them up.
51 setlinecap is *not* a proper solution.
52
53 Need a better way than MAX_WORKSPACE to detect low-memory conditions.
54
55 When malloc() returns 0, page to disk and free() unnecessary data.
56
57 Remove ccase * argument from procfunc argument to procedure().
58
59 See if process_active_file() has wider applicability.
60
61 Looks like there's a potential problem with value labels--we use free_val_lab
62 from avl_destroy(), but free_val_lab doesn't decrement the reference count, it
63 just frees the label.  Check into this sometime soon.
64
65 Eliminate private data in struct variable through use of pointers.
66
67 Fix som_columns().
68
69 There needs to be another layer onto the lexer, which should probably be
70 entirely rewritten anyway.  The lexer needs to read entire *commands* at a
71 time, not just a *line* at a time.  This would vastly simplify the
72 (yet-to-be-implemented) logging mechanism and other stuff as well.
73            
74 Has glob.c been pared down enough?
75
76 Improve interactivity of output by allowing a `commit' function for a page.
77 This will also allow for infinite-length pages.
78
79 All the tests need to be looked over.  Some of the SET calls don't make sense
80 any more.
81
82 Implement thin single lines, should be pretty easy now.
83
84 SELECT IF should be moved before other transformations whenever possible.  It
85 should only be impossible when one of the variables referred to in SELECT IF is
86 created or modified by a previous transformation.
87
88 The manual: add text, add index entries, add examples.
89
90 The inline file should be improved: There should be *real* detection of whether
91 it is used (in dfm.c:cmd_begin_data), not after-the-fact detection.
92
93 Figure out a stylesheet for messages displayed by PSPP: i.e., what quotation
94 marks around filenames, etc.
95
96 Data input and data output are currently arranged in reciprocal pairs: input is
97 done directly, with write_record() or whatever; output is done on a callback
98 event-driven basis.  It would definitely be easier if both could be done on a
99 direct basis, with read_record() and write_record() routines, with a coroutine
100 implementation (see Knuth).  But I'm not sure that coroutines can be
101 implemented in ANSI C.  This will require some thought.  Perhaps 0.4.0 can do
102 this.
103
104 New SET subcommand: OUTPUT.  i.e., SET OUTPUT="filename" to send output to that
105 file; SET OUTPUT="filename"(APPEND) to append to that file; SET OUTPUT=DEFAULT
106 to reset everything.  There might be a better approach, though--think about it.
107
108 HDF export capabilities (http://hdf.ncsa.uiuc.edu).  Suggested by Marcus
109 G. Daniels <mgd@santafe.edu>.
110
111 From Zvi Grauer <z.grauer@csuohio.edu> and <zvi@mail.ohio.net>:
112
113    1. design of experiments software, specifically Factorial, response surface
114    methodology and mixrture design.  
115
116    These would be EXTREMELY USEFUL for chemists, engineeris, and anyone
117    involved in the production of chemicals or formulations.
118
119    2. Multidimensional Scaling analysis (for market analysis) - 
120
121    3. Preference mapping software for market analysis
122
123    4. Hierarchical clustering (as well as partition clustering)
124
125    5. Conjoint analysis
126
127    6. Categorical data analsys ?
128
129 IDEAS
130 -----
131
132 In addition to an "infinite journal", we should keep a number of
133 individual-session journals, pspp.jnl-1 through pspp.jnl-X, renaming and
134 deleting as needed.  All of the journals should have date/time comments.
135
136 Qualifiers for variables giving type--categorical, ordinal, ...
137
138 Analysis Wizard
139
140 Consider consequences of xmalloc(), fail(), hcf() in interactive
141 use:
142 a. Can we safely just use setjmp()/longjmp()?
143 b. Will that leak memory?
144 i. I don't think so: all procedure-created memory is either
145 garbage-collected or globally-accessible.
146 ii. But you never know... esp. w/o Checker.
147 c. Is this too early to worry? too late?
148
149 Need to implement a shared buffer for funny functions that require relatively
150 large permanent transient buffers (1024 bytes or so), that is, buffers that are
151 permanent in the sense that they probably shouldn't be deallocated but are only
152 used from time to time, buffers that can't be allocated on the stack because
153 they are of variable and unpredictable but usually relatively small (usually
154 line buffers).  There are too many of these lurking around; can save a sizeable
155 amount of space at very little overhead and with very little effort by merging
156 them.
157
158 Clever multiplatform GUI idea (due partly to John Williams): write a GUI in
159 Java where each statistical procedure dialog box could be downloaded from the
160 server independently.  The statistical procedures would run on (the/a) server
161 and results would be reported through HTML tables viewed with the user's choice
162 of web browsers.  Help could be implemented through the browser as well.
163
164 Design a plotting API, with scatterplots, line plots, pie charts, barcharts,
165 Pareto plots, etc., as subclasses of the plot superclass.
166
167 HOWTOs
168 ------
169
170 1. How to add an operator for use in PSPP expressions:
171
172 a. Add the operator to the enumerated type at the top of expr.h.  If the
173 operator has arguments (i.e., it's not a terminal) then add it *before*
174 OP_TERMINAL; otherwise, add it *after* OP_TERMINAL.  All these begin with OP_.
175
176 b. If the operator's a terminal then you'll want to design a structure to hold
177 its content.  Add the structure to the union any_node.  (You can also reuse one
178 of the prefab structures, of course.)
179
180 c. Now switch to expr-prs.c--the module for expression parsing.  Insert the
181 operator somewhere in the precedence hierarchy.
182
183 (1) If you're adding a operator that is a function (like ACOS, ABS, etc.) then
184 add the function to functab in `void init_functab(void)'.  Order is not
185 important here.  The first element is the function name, like "ACOS".  The
186 second is the operator enumerator you added in expr.h, like OP_ARCOS.  The
187 third element is the C function to parse the PSPP function.  The predefined
188 functions will probably suit your needs, but if not, you can write your own.
189 The fourth element is an argument to the parsing function; it's only used
190 currently by generic_str_func(), which handles a rather general syntax for
191 functions that return strings; see the comment at the beginning of its code for
192 details.
193
194 (2) If you're adding an actual operator you'll have to put a function in
195 between two of the operators there already in functions `exprtype
196 parse_*(any_node **n)'.  Each of these stores the tree for its result into *n,
197 and returns the result type, or EX_ERROR on error.  Be sure to delete all the
198 allocated memory on error before returning.
199
200 d. Add the operator to the table `op_desc ops[OP_SENTINEL+1]' in expr-prs.c,
201 which has an entry for every operator.  These entries *must* be in the same
202 order as they are in expr.h.  The entries have the form `op(A,B,C,D)'.  A is
203 the name of the operator as it should be printed in a postfix output format.
204 For example, the addition operator is printed as `plus'.  B is a bitmapped set
205 of flags:
206
207 * Set the 001 bit (OP_VAR_ARGS) if the operator takes a variable number of
208 arguments.  If a function can take, say, two args or three args, but no other
209 numbers of args, this is a poor way to do it--instead implement the operator as
210 two separate operators, one with two args, the other with three.  (The main
211 effect of this bit is to cause the number of arguments to be output to the
212 postfix form so that the expression evaluator can know how many args the
213 operator takes.  It also causes the expression optimizer to calculate the
214 needed stack height differently, without referencing C.)
215
216 * Set the 002 bit (OP_MIN_ARGS) if the operator can take an optional `dotted
217 argument' that specified the minimum number of non-SYSMIS arguments in order to
218 have a non-SYSMIS result.  For instance, MIN.3(e1,e2,e3,e4,e5) returns a
219 non-SYSMIS result only if at least 3 out of 5 of the expressions e1 to e5 are
220 not missing.
221
222 Minargs are passed in the nonterm_node structure in `arg[]''s elements past
223 `n'--search expr-prs.c for the words `terrible crock' for an example of this.
224
225 Minargs are output to the postfix form.  A default value is output if none was
226 specified by the user.
227
228 You can use minargs for anything you want--they're not limited to actually
229 describing a minimum number of valid arguments; that's just what they're most
230 *commonly* used for.
231
232 * Set the 004 bit (OP_FMT_SPEC) if the operator has an argument that is a
233 format specifier.  (This causes the format specifier to be output to the
234 postfix representation.)
235
236 Format specs are passed in the nonterm_node structure in the same way as
237 minargs, except that there are three args, in this order: type, width, # of
238 decimals--search expr-prs.c for the words `is a crock' for an example of this.
239
240 * Set the 010 bit (OP_ABSORB_MISS) if the operator can *ever* have a result of
241 other than SYSMIS when given one or more arguments of SYSMIS.  Operators
242 lacking this bit and known to have a SYSMIS argument are short-circuited to
243 SYSMIS by the expression optimizer.
244
245 * If your operator doesn't fit easily into the existing categories,
246 congratulations, you get to write lots of code to adjust everything to cope
247 with this new operator.  Are you really sure you want to do that?
248
249 C is the effect the operator has on stack height.  Set this to `varies' if the
250 operator has a variable number of arguments.  Otherwise this 1, minus the
251 number of arguments the operator has.  (Since terminals have no arguments, they
252 have a value of +1 for this; other operators have a value of 0 or less.)
253
254 D is the number of items output to the postfix form after the operator proper.
255 This is 0, plus 1 if the operator has varargs, plus 1 if the operator has
256 minargs, plus 3 if the operator has a format spec.  Note that minargs/varargs
257 can't coexist with a format spec on the same operator as currently coded.  Some
258 terminals also have a nonzero value for this but don't fit into the above
259 categories.
260
261 e. Switch to expr-opt.c.  Add code to evaluate_tree() to evaluate the
262 expression when all arguments are known to be constants.  Pseudo-random
263 functions can't be evaluated even if their arguments are constants.  If the
264 function can be optimized even if its arguments aren't all known constants, add
265 code to optimize_tree() to do it.
266
267 f. Switch to expr-evl.c.  Add code to evaluate_expression() to evaluate the
268 expression.  You must be absolutely certain that the code in evaluate_tree(),
269 optimize_tree(), and evaluate_expression() will always return the same results,
270 otherwise users will get inconsistent results, a Bad Thing.  You must be
271 certain that even on boundary conditions users will get identical results, for
272 instance for the values 0, 1, -1, SYSMIS, or, for string functions, the null
273 string, 1-char strings, and 255-char strings.
274
275 g. Test the code.  Write some test syntax files.  Examine the output carefully.
276
277 NOTES ON SEARCH ALGORITHMS
278 --------------------------
279
280 1. Trees are nicer when you want a sorted table.  However, you can always
281 sort a hash table after you're done adding values.
282
283 2. Brent's variation of Algorithm D is best when the table is fixed: it's
284 memory-efficient, having small, fixed overhead.  It's easier to use
285 when you know in advance how many entries the table will contain.
286
287 3. Algorithm L is rather slow for a hash algorithm, however it's easy.
288
289 4. Chaining is best in terms of speed; ordered/self-ordering is even
290 better.
291
292 5. Rehashing is slow.
293
294 6. Might want to decide on an algorithm empirically since there are no
295 clear mathematical winners in some cases.
296
297 7. gprof?  Hey, it works!
298
299 MORE NOTES/IDEAS/BUGS
300 ---------------------
301
302 The behavior of converting a floating point to an integer when the value of the
303 float is out of range of the integer type is UNDEFINED!  See ANSI 6.2.1.3.
304
305 What should we do for *negative* times in expressions?
306
307 Sometimes very wide (or very tall) columns can occur in tables.  What is a good
308 way to truncate them?  It doesn't seem to cause problems for the ascii or
309 postscript drivers, but it's not good in the general case.  Should they be
310 split somehow?  (One way that wide columns can occur is through user request,
311 for instance through a wide PRINT request--try time-date.stat with a narrow
312 ascii page or with the postscript driver on letter size paper.)
313
314 NULs in input files break the products we're replacing: although it will input
315 them properly and display them properly as AHEX format, it truncates them in A
316 format.  Also, string-manipulation functions such as CONCAT truncate their
317 results after the first NUL.  This should simplify the result of PSPP design.
318 Perhaps those ugly a_string, b_string, ..., can all be eliminated.
319
320 From Moshe Braner <mbraner@nessie.vdh.state.vt.us>: An idea regarding MATCH
321 FILES, again getting BEYOND the state of SPSS: it always bothered me that if I
322 have a large data file and I want to match it to a small lookup table, via
323 MATCH FILES FILE= /TABLE= /BY key, I need to SORT the large file on key, do the
324 match, then (usually) re-sort back into the order I really want it.  There is
325 no reason to do this, when the lookup table is small.  Even a dumb sequential
326 search through the table, for every case in the big file, is better, in some
327 cases, than the sort.  So here's my idea: first look at the /TABLE file, if it
328 is "small enough", read it into memory, and create an index (or hash table,
329 whatever) for it.  Then read the /FILE and use the index to match to each case.
330 OTOH, if the /TABLE is too large, then do it the old way, complaining if either
331 file is not sorted on key.
332
333 -------------------------------------------------------------------------------
334 Local Variables:
335 mode: text
336 fill-column: 79
337 End: