Re: Should we MAY a "curly-write" and "neoteric-write"? Or even "sweet-write"? David A. Wheeler (10 Apr 2013 04:11 UTC)
Draft updated SRFI-110 and reference implementation David A. Wheeler (15 Apr 2013 04:09 UTC)

Re: Should we MAY a "curly-write" and "neoteric-write"? Or even "sweet-write"? David A. Wheeler 10 Apr 2013 04:11 UTC

Below is a more detailed example of what I had in mind.  Below is the core of a "neoteric-write-simple" (no port option yet)... followed by example output.

--- David A. Wheeler

===================================================

(define (neoteric-write-simple x)
  (cond
    ((pair? x)
      (cond
        ((represent-as-abbreviation? x)              ; Format 'x
          (display (list->string (cadr (assq (car x) abbreviations))))
          (neoteric-write-simple (cadr x)))
        ((or (long-and-boring? x) (not (list? x)))
          (display "(")                              ; Format (a b c ...)
          (neoteric-write-unit-list x)
          (display ")"))
        ((symbol? (car x))
          (cond
            ((represent-as-inline-infix? x)          ; Format {a + b}
              (display "{")
              (neoteric-write-simple (cadr x))
              (infix-tail (car x) (cddr x)))
            ((and (list1? (cdr x))
              (pair? (cadr x))
              (represent-as-brace-suffix? (cadr x))) ; Format f{...}
                (neoteric-write-simple (car x))
                (as-brace-suffix (cadr x)))
            (#t                                      ; Format f(...)
              (neoteric-write-simple (car x))
              (display "(")
              (neoteric-write-unit-list (cdr x))
              (display ")"))))
        (#t                                          ; Format (1 2 3 ...)
          (display "(")
          (neoteric-write-unit-list x)
          (display ")"))))
    (#t (write x))))                                 ; Everything else.

=====================================================
Sample output:

'x
(a b c d e f g h i j k l m n o p q r s t u v w x y z)
{a + b}
{a + b + c}
sin{- theta}
fact{n - 1}
between(current min max)
sin(x)
current-time()
(1 2 3)
5
boring-symbol
{sqrt(x) + sqrt(y)}