Add TODO item.
[pspp-builds.git] / TODO
1 Time-stamp: <2004-03-26 01:12:33 blp>
2
3 What Ben's working on now.
4 --------------------------
5
6 Procedures need to be able to make multiple passes.
7
8 Write a better descriptive stats evaluator based on NR two-pass technique,
9 revise all existing code to use it.
10
11 Update q2c input format description.
12
13 Rewrite output subsystem, break into multiple processes.
14
15 CROSSTABS needs to be re-examined.
16
17 TODO
18 ----
19
20 Expressions need to be able to abbreviate function names.  XDATE.QUARTER
21 abbreviates to XDA.QUA, etc.
22
23 The expression tests need tests for XDATE and a few others, see
24 tests/xforms/expressions.sh comments for details.
25
26 Expressions need random distribution functions.
27
28 There needs to be another layer onto the lexer, which should probably be
29 entirely rewritten anyway.  The lexer needs to read entire *commands* at a
30 time, not just a *line* at a time.  It also needs to support arbitrary putback,
31 probably by just backing up the "current position" in the command buffer.
32
33 Scratch variables should not be available for use following TEMPORARY.
34
35 Details of N OF CASES, SAMPLE, FILTER, PROCESS IF, TEMPORARY, etc., need to be
36 checked against the documentation.  See notes on these at end of file for a
37 start.
38
39 Check our results against the NIST StRD benchmark results at
40 strd.itl.nist.gov/div898/strd
41
42 In debug mode hash table code should verify that collisions are reasonably low.
43
44 Use posix_fadvise(POSIX_FADV_SEQUENTIAL) where available.
45
46 Use AFM files instead of Groff font files, and include AFMs for our default
47 fonts with the distribution.
48
49 Add libplot output driver.  Suggested by Robert S. Maier
50 <rsm@math.arizona.edu>: "it produces output in idraw-editable PS format, PCL5
51 format, xfig-editable format, Illustrator format,..., and can draw vector
52 graphics on X11 displays also".
53
54 Storage of value labels on disk is inefficient.  Invent new data structure.
55
56 Add an output flag which would cause a page break if a table segment could fit
57 vertically on a page but it just happens to be positioned such that it won't.
58
59 Fix spanned joint cells, i.e., EDLEVEL on crosstabs.stat.
60
61 Cell footnotes.
62
63 PostScript driver should emit thin lines, then thick lines, to optimize time
64 and space.
65
66 New functions?  var_name_or_label(), tab_value_or_label()
67
68 Should be able to bottom-justify cells.  It'll be expensive, though, by
69 requiring an extra metrics call.
70
71 Perhaps instead of the current lines we should define the following line types:
72 null, thin, thick, double.  It might look pretty classy.
73
74 Perhaps thick table borders that are cut off by a page break should decay to
75 thin borders.  (i.e., on a thick bordered table that's longer than one page,
76 but narrow, the bottom border would be thin on the first page, and the top and
77 bottom borders on middle pages.)
78
79 Support multi-line titles on tables. (For the first page only, presumably.)
80
81 Rewrite the convert_F() function in data-out.c to be nicer code.
82
83 In addition to searching the source directory, we should search the current
84 directory (for data files).  (Yuck!)
85
86 Fix line-too-long problems in PostScript code, instead of covering them up.
87 setlinecap is *not* a proper solution.
88
89 Need a better way than MAX_WORKSPACE to detect low-memory conditions.
90
91 When malloc() returns 0, page to disk and free() unnecessary data.
92
93 Remove ccase * argument from procfunc argument to procedure().
94
95 See if process_active_file() has wider applicability.
96
97 Eliminate private data in struct variable through use of pointers.
98
99 Fix som_columns().
100
101 Has glob.c been pared down enough?
102
103 Improve interactivity of output by allowing a `commit' function for a page.
104 This will also allow for infinite-length pages.
105
106 All the tests need to be looked over.  Some of the SET calls don't make sense
107 any more.
108
109 Implement thin single lines, should be pretty easy now.
110
111 SELECT IF should be moved before other transformations whenever possible.  It
112 should only be impossible when one of the variables referred to in SELECT IF is
113 created or modified by a previous transformation.
114
115 The manual: add text, add index entries, add examples.
116
117 The inline file should be improved: There should be *real* detection of whether
118 it is used (in dfm.c:cmd_begin_data), not after-the-fact detection.
119
120 Figure out a stylesheet for messages displayed by PSPP: i.e., what quotation
121 marks around filenames, etc.
122
123 Data input and data output are currently arranged in reciprocal pairs: input is
124 done directly, with write_record() or whatever; output is done on a callback
125 event-driven basis.  It would definitely be easier if both could be done on a
126 direct basis, with read_record() and write_record() routines, with a coroutine
127 implementation (see Knuth).  But I'm not sure that coroutines can be
128 implemented in ANSI C.  This will require some thought.  Perhaps 0.4.0 can do
129 this.
130
131 New SET subcommand: OUTPUT.  i.e., SET OUTPUT="filename" to send output to that
132 file; SET OUTPUT="filename"(APPEND) to append to that file; SET OUTPUT=DEFAULT
133 to reset everything.  There might be a better approach, though--think about it.
134
135 HDF export capabilities (http://hdf.ncsa.uiuc.edu).  Suggested by Marcus
136 G. Daniels <mgd@santafe.edu>.
137
138 From Zvi Grauer <z.grauer@csuohio.edu> and <zvi@mail.ohio.net>:
139
140    1. design of experiments software, specifically Factorial, response surface
141    methodology and mixrture design.
142
143    These would be EXTREMELY USEFUL for chemists, engineeris, and anyone
144    involved in the production of chemicals or formulations.
145
146    2. Multidimensional Scaling analysis (for market analysis) -
147
148    3. Preference mapping software for market analysis
149
150    4. Hierarchical clustering (as well as partition clustering)
151
152    5. Conjoint analysis
153
154    6. Categorical data analsys ?
155
156 IDEAS
157 -----
158
159 In addition to an "infinite journal", we should keep a number of
160 individual-session journals, pspp.jnl-1 through pspp.jnl-X, renaming and
161 deleting as needed.  All of the journals should have date/time comments.
162
163 Qualifiers for variables giving type--categorical, ordinal, ...
164
165 Analysis Wizard
166
167 Consider consequences of xmalloc(), fail(), hcf() in interactive
168 use:
169 a. Can we safely just use setjmp()/longjmp()?
170 b. Will that leak memory?
171 i. I don't think so: all procedure-created memory is either
172 garbage-collected or globally-accessible.
173 ii. But you never know... esp. w/o Checker.
174 c. Is this too early to worry? too late?
175
176 Need to implement a shared buffer for funny functions that require relatively
177 large permanent transient buffers (1024 bytes or so), that is, buffers that are
178 permanent in the sense that they probably shouldn't be deallocated but are only
179 used from time to time, buffers that can't be allocated on the stack because
180 they are of variable and unpredictable but usually relatively small (usually
181 line buffers).  There are too many of these lurking around; can save a sizeable
182 amount of space at very little overhead and with very little effort by merging
183 them.
184
185 Clever multiplatform GUI idea (due partly to John Williams): write a GUI in
186 Java where each statistical procedure dialog box could be downloaded from the
187 server independently.  The statistical procedures would run on (the/a) server
188 and results would be reported through HTML tables viewed with the user's choice
189 of web browsers.  Help could be implemented through the browser as well.
190
191 Design a plotting API, with scatterplots, line plots, pie charts, barcharts,
192 Pareto plots, etc., as subclasses of the plot superclass.
193
194 HOWTOs
195 ------
196
197 1. How to add an operator for use in PSPP expressions:
198
199 a. Add the operator to the enumerated type at the top of expr.h.  If the
200 operator has arguments (i.e., it's not a terminal) then add it *before*
201 OP_TERMINAL; otherwise, add it *after* OP_TERMINAL.  All these begin with OP_.
202
203 b. If the operator's a terminal then you'll want to design a structure to hold
204 its content.  Add the structure to the union any_node.  (You can also reuse one
205 of the prefab structures, of course.)
206
207 c. Now switch to expr-prs.c--the module for expression parsing.  Insert the
208 operator somewhere in the precedence hierarchy.
209
210 (1) If you're adding a operator that is a function (like ACOS, ABS, etc.) then
211 add the function to functab in `void init_functab(void)'.  Order is not
212 important here.  The first element is the function name, like "ACOS".  The
213 second is the operator enumerator you added in expr.h, like OP_ARCOS.  The
214 third element is the C function to parse the PSPP function.  The predefined
215 functions will probably suit your needs, but if not, you can write your own.
216 The fourth element is an argument to the parsing function; it's only used
217 currently by generic_str_func(), which handles a rather general syntax for
218 functions that return strings; see the comment at the beginning of its code for
219 details.
220
221 (2) If you're adding an actual operator you'll have to put a function in
222 between two of the operators there already in functions `exprtype
223 parse_*(any_node **n)'.  Each of these stores the tree for its result into *n,
224 and returns the result type, or EX_ERROR on error.  Be sure to delete all the
225 allocated memory on error before returning.
226
227 d. Add the operator to the table `op_desc ops[OP_SENTINEL+1]' in expr-prs.c,
228 which has an entry for every operator.  These entries *must* be in the same
229 order as they are in expr.h.  The entries have the form `op(A,B,C,D)'.  A is
230 the name of the operator as it should be printed in a postfix output format.
231 For example, the addition operator is printed as `plus'.  B is a bitmapped set
232 of flags:
233
234 * Set the 001 bit (OP_VAR_ARGS) if the operator takes a variable number of
235 arguments.  If a function can take, say, two args or three args, but no other
236 numbers of args, this is a poor way to do it--instead implement the operator as
237 two separate operators, one with two args, the other with three.  (The main
238 effect of this bit is to cause the number of arguments to be output to the
239 postfix form so that the expression evaluator can know how many args the
240 operator takes.  It also causes the expression optimizer to calculate the
241 needed stack height differently, without referencing C.)
242
243 * Set the 002 bit (OP_MIN_ARGS) if the operator can take an optional `dotted
244 argument' that specified the minimum number of non-SYSMIS arguments in order to
245 have a non-SYSMIS result.  For instance, MIN.3(e1,e2,e3,e4,e5) returns a
246 non-SYSMIS result only if at least 3 out of 5 of the expressions e1 to e5 are
247 not missing.
248
249 Minargs are passed in the nonterm_node structure in `arg[]''s elements past
250 `n'--search expr-prs.c for the words `terrible crock' for an example of this.
251
252 Minargs are output to the postfix form.  A default value is output if none was
253 specified by the user.
254
255 You can use minargs for anything you want--they're not limited to actually
256 describing a minimum number of valid arguments; that's just what they're most
257 *commonly* used for.
258
259 * Set the 004 bit (OP_FMT_SPEC) if the operator has an argument that is a
260 format specifier.  (This causes the format specifier to be output to the
261 postfix representation.)
262
263 Format specs are passed in the nonterm_node structure in the same way as
264 minargs, except that there are three args, in this order: type, width, # of
265 decimals--search expr-prs.c for the words `is a crock' for an example of this.
266
267 * Set the 010 bit (OP_ABSORB_MISS) if the operator can *ever* have a result of
268 other than SYSMIS when given one or more arguments of SYSMIS.  Operators
269 lacking this bit and known to have a SYSMIS argument are short-circuited to
270 SYSMIS by the expression optimizer.
271
272 * If your operator doesn't fit easily into the existing categories,
273 congratulations, you get to write lots of code to adjust everything to cope
274 with this new operator.  Are you really sure you want to do that?
275
276 C is the effect the operator has on stack height.  Set this to `varies' if the
277 operator has a variable number of arguments.  Otherwise this 1, minus the
278 number of arguments the operator has.  (Since terminals have no arguments, they
279 have a value of +1 for this; other operators have a value of 0 or less.)
280
281 D is the number of items output to the postfix form after the operator proper.
282 This is 0, plus 1 if the operator has varargs, plus 1 if the operator has
283 minargs, plus 3 if the operator has a format spec.  Note that minargs/varargs
284 can't coexist with a format spec on the same operator as currently coded.  Some
285 terminals also have a nonzero value for this but don't fit into the above
286 categories.
287
288 e. Switch to expr-opt.c.  Add code to evaluate_tree() to evaluate the
289 expression when all arguments are known to be constants.  Pseudo-random
290 functions can't be evaluated even if their arguments are constants.  If the
291 function can be optimized even if its arguments aren't all known constants, add
292 code to optimize_tree() to do it.
293
294 f. Switch to expr-evl.c.  Add code to evaluate_expression() to evaluate the
295 expression.  You must be absolutely certain that the code in evaluate_tree(),
296 optimize_tree(), and evaluate_expression() will always return the same results,
297 otherwise users will get inconsistent results, a Bad Thing.  You must be
298 certain that even on boundary conditions users will get identical results, for
299 instance for the values 0, 1, -1, SYSMIS, or, for string functions, the null
300 string, 1-char strings, and 255-char strings.
301
302 g. Test the code.  Write some test syntax files.  Examine the output carefully.
303
304 NOTES ON SEARCH ALGORITHMS
305 --------------------------
306
307 1. Trees are nicer when you want a sorted table.  However, you can always
308 sort a hash table after you're done adding values.
309
310 2. Brent's variation of Algorithm D is best when the table is fixed: it's
311 memory-efficient, having small, fixed overhead.  It's easier to use
312 when you know in advance how many entries the table will contain.
313
314 3. Algorithm L is rather slow for a hash algorithm, however it's easy.
315
316 4. Chaining is best in terms of speed; ordered/self-ordering is even
317 better.
318
319 5. Rehashing is slow.
320
321 6. Might want to decide on an algorithm empirically since there are no
322 clear mathematical winners in some cases.
323
324 7. gprof?  Hey, it works!
325
326 MORE NOTES/IDEAS/BUGS
327 ---------------------
328
329 The behavior of converting a floating point to an integer when the value of the
330 float is out of range of the integer type is UNDEFINED!  See ANSI 6.2.1.3.
331
332 What should we do for *negative* times in expressions?
333
334 Sometimes very wide (or very tall) columns can occur in tables.  What is a good
335 way to truncate them?  It doesn't seem to cause problems for the ascii or
336 postscript drivers, but it's not good in the general case.  Should they be
337 split somehow?  (One way that wide columns can occur is through user request,
338 for instance through a wide PRINT request--try time-date.stat with a narrow
339 ascii page or with the postscript driver on letter size paper.)
340
341 NULs in input files break the products we're replacing: although it will input
342 them properly and display them properly as AHEX format, it truncates them in A
343 format.  Also, string-manipulation functions such as CONCAT truncate their
344 results after the first NUL.  This should simplify the result of PSPP design.
345 Perhaps those ugly a_string, b_string, ..., can all be eliminated.
346
347 From Moshe Braner <mbraner@nessie.vdh.state.vt.us>: An idea regarding MATCH
348 FILES, again getting BEYOND the state of SPSS: it always bothered me that if I
349 have a large data file and I want to match it to a small lookup table, via
350 MATCH FILES FILE= /TABLE= /BY key, I need to SORT the large file on key, do the
351 match, then (usually) re-sort back into the order I really want it.  There is
352 no reason to do this, when the lookup table is small.  Even a dumb sequential
353 search through the table, for every case in the big file, is better, in some
354 cases, than the sort.  So here's my idea: first look at the /TABLE file, if it
355 is "small enough", read it into memory, and create an index (or hash table,
356 whatever) for it.  Then read the /FILE and use the index to match to each case.
357 OTOH, if the /TABLE is too large, then do it the old way, complaining if either
358 file is not sorted on key.
359
360 ----------------------------------------------------------------------
361 Statistical procedures:
362
363 For each case we read from the input program:
364
365 1. Execute permanent transformations.  If these drop the case, stop.
366 2. N OF CASES.  If we have already written N cases, stop.
367 3. Write case to replacement active file.
368 4. Execute temporary transformations.  If these drop the case, stop.
369 5. Post-TEMPORARY N OF CASES.  If we have already analyzed N cases, stop.
370 6. FILTER, PROCESS IF.  If these drop the case, go to 5.
371 7. Pass case to procedure.
372
373 Ugly cases:
374
375 LAG records cases in step 3.
376
377 AGGREGATE: When output goes to an external file, this is just an ordinary
378 procedure.  When output goes to the active file, step 3 should be skipped,
379 because AGGREGATE creates its own case sink and writes to it in step 7.  Also,
380 TEMPORARY has no effect and we just cancel it.  Regardless of direction of
381 output, we should not implement AGGREGATE through a transformation because that
382 will fail to honor FILTER, PROCESS IF, N OF CASES.
383
384 ADD FILES: Essentially an input program.  It silently cancels unclosed LOOPs
385 and DO IFs.  If the active file is used for input, then runs EXECUTE (if there
386 are any transformations) and then steals vfm_source and encapsulates it.  If
387 the active file is not used for input, then it cancels all the transformations
388 and deletes the original active file.
389
390 CASESTOVARS: ???
391
392 FLIP:
393
394 MATCH FILES: Similar to AGGREGATE.  This is a procedure.  When the active file
395 is used for input, it reads the active file; otherwise, it just cancels all the
396 transformations and deletes the original active file.  Step 3 should be
397 skipped, because MATCH FILES creates its own case sink and writes to it in step
398 7.  TEMPORARY is not allowed.
399
400 MODIFY VARS:
401
402 REPEATING DATA:
403
404 SORT CASES:
405
406 UPDATE: same as ADD FILES.
407
408 VARSTOCASES: ???
409 ----------------------------------------------------------------------
410 N OF CASES
411
412   * Before TEMPORARY, limits number of cases sent to the sink.
413
414   * After TEMPORARY, limits number of cases sent to the procedure.
415
416   * Without TEMPORARY, those are the same cases, so it limits both.
417
418 SAMPLE
419
420   * Sample is just a transformation.  It has no special properties.
421
422 FILTER
423
424   * Always selects cases sent to the procedure.
425
426   * No effect on cases sent to sink.
427
428   * Before TEMPORARY, selection is permanent.  After TEMPORARY,
429     selection stops after a procedure.
430
431 PROCESS IF
432
433   * Always selects cases sent to the procedure.
434
435   * No effect on cases sent to sink.
436
437   * Always stops after a procedure.
438
439 SPLIT FILE
440
441   * Ignored by AGGREGATE.  Used when procedures write matrices.
442
443   * Always applies to the procedure.
444
445   * Before TEMPORARY, splitting is permanent.  After TEMPORARY,
446     splitting stops after a procedure.
447
448 TEMPORARY
449
450   * TEMPORARY has no effect on AGGREGATE when output goes to the active file.
451
452   * SORT CASES, ADD FILES, RENAME VARIABLES, CASESTOVARS, VARSTOCASES,
453     COMPUTE with a lag function cannot be used after TEMPORARY.
454
455   * Cannot be used in DO IF...END IF or LOOP...END LOOP.
456
457   * FLIP ignores TEMPORARY.  All transformations become permanent.
458
459   * MATCH FILES and UPDATE cannot be used after TEMPORARY if active
460     file is an input source.
461
462   * RENAME VARIABLES is invalid after TEMPORARY.
463
464   * WEIGHT, SPLIT FILE, N OF CASES, FILTER, PROCESS IF apply only to
465     the next procedure when used after TEMPORARY.
466
467 WEIGHT
468
469   * Always applies to the procedure.
470
471   * Before TEMPORARY, weighting is permanent.  After TEMPORARY,
472     weighting stops after a procedure.
473
474
475 -------------------------------------------------------------------------------
476 Local Variables:
477 mode: text
478 fill-column: 79
479 End: