[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should we MAY a "curly-write" and "neoteric-write"? Or even "sweet-write"?



Mark H Weaver:
> Such procedures would have to include very complicated heuristics to
> decide when to use traditional s-expressions, when to use curly-infix,
> when to use neoteric, etc.  The heuristics would have to make
> assumptions based on the symbol names.  Personally, I think it would be
> very hard to produce good output.

A fair concern.  For sweet-expressions it *is* complicated, because it's basically a pretty-printer.  Which is why I think we should NOT have a "sweet-write" in this SRFI, as that is probably best handled separately.  (Pretty-printers are *already* handled separately today, for all the same reasons.)

But I think curly-write and neoteric-write aren't too bad.  They do not need to be "perfect" in the sense that a human would do the same thing, they just need to be pleasant to use and provide a quick way to write info.  If someone wants a different display, he can write his own procedure.  I don't think we need to specify exactly what these writers do, just that they have to produce a representation of the object according to the notation.  All of these statements are *already* true for "write", e.g., nobody mandates the characters that "(write (quote x))" produces.

Of course we *do* need to provide a sample implementation, and they should be useful.  However, I already have simple heuristics that I think work pretty well for neoteric expressions.  Try this in order:

1. Represent a list as (...elements...) if there are 16+ elements, none of which are a pair.  (These are "boring lists" because they're unlikely to represent procedure calls.)

2. Represent a list x as {...} infix if it:
* Begins with a symbol that is ONLY punctuation or one of '(and or xor)
* AND it's a proper list of length 3..6 or less

3. Otherwise, represent a list x as f{...} if:
* Begins with a symbol, its cdr is a (proper) list of length 1 (1 param)
* cadr(x) is a list
* The cadr(x) meets the infix requirements above, but length is 2..6.

4. Otherwise, represent a list as f(...) if:
* Begins with a symbol

5. Otherwise represent a list as (...elements...)

6. Represent the rest normally.


Curly-infix can start with the infix rule, and once inside switch to the neoteric rule.


--- David A. Wheeler