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