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