Looking at complicated format strings (in cl-format) such as:

  "~:<~:@{[~25s ~30s]~:^~:@_~}~:>"

I'm struck with a desire to break up the string, comment it, etc.  In fact, in
http://wiki.cfcl.com/bin/view/Projects/Clojure/CP_pprint, I did so:

  "~:<~:@{[~25s ~30s]~:^~:@_~}~:>"  ; the entire format string
   ~:<                        ~:>   ; creates a logical block
      ~:@{                  ~}      ; iterates through the vectors in the list
          [         ]               ; creates a pair of literal brackets
           ~25s ~30s                ; creates a pair of fixed-width columns
                     ~:^            ; breaks the iteration on the last pair
                        ~:@_        ; creates a mandatory newline


This works OK as an expository format, but it seems a bit picky and inflexible
(ie, placement of white space is critical).  It might also be hard to parse.


Perl Regular expressions can be written in an "extended mode" where white space
(including comments) is ignored.  Something like this might work for cl-format,
using ~w to generate white space:

  (def fmt (em "
    ~:< ~:@{           ; create logical block, iterate through list
    [ ~25s ~w ~30s ]   ; create bracketed, fixed-width columns
    ~:^ ~:@_           ; break iteration, create mandatory newline
    ~} ~:>             ; close out iteration and logical block
  "))

However, I'm not convinced that this is the ideal syntax.  Suggestions?

-r

 -- 
http://www.cfcl.com/rdm            Rich Morin
http://www.cfcl.com/rdm/resume     r...@cfcl.com
http://www.cfcl.com/rdm/weblog     +1 650-873-7841

Software system design, development, and documentation


-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to