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