[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"?

This page is part of the web mail archives of SRFI 110 from before July 7th, 2015. The new archives for SRFI 110 contain all messages, not just those from before July 7th, 2015.

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)
    ((pair? x)
        ((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))
            ((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:

(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)
(1 2 3)
{sqrt(x) + sqrt(y)}