Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Multiple docstring lines

From: tim-johnsons::web::com at: 4-Jun-2007 15:29

For years, I've been irritated by the way that emacs handles multiple line strings for syntax highlighting - IOWS, it just doesn't work that well. Soo.... this is what I tried: With one large file as a test case - a "library" of reusable routines - I replaced multiple line docstrings with multiple lines of docstrings. Here's an example: swaps: def[{Swaps pairs in block. Block must be of even length. Example: swaps[2 1 4 3 6 5] => [1 2 3 4 5 6]}[catch] blk[block!] ][ if not even? (length? blk)[toss["'blk argument must be of even length."]] foreach [a b] blk yield[reduce[b a]] ] ;; with multiple docstrings: swaps: def["Swaps pairs in block. Block must be of even length." " Example: swaps[2 1 4 3 6 5] => [1 2 3 4 5 6]"[catch] blk[block!] ][ if not even? (length? blk)[toss["'blk argument must be of even length."]] foreach [a b] blk yield[reduce[b a]] ] I then created a function called 'helpn by copying the source for 'help and replacing: either string? pick args 1 [ print [tab first args] args: next args ...... ;; with either string? pick args 1 [ while[string? pick args 1][ print [tab first args] args: next args ] As a result 'helpn picks up the multiple lines, and since the routines in this file are used very widely in my code, I have not yet seen any problems. It looks like rebol ignores any strings when parsing the interface specification block for any function. Now my syntax highlighting is no longer scrambled, and I find I have more flexibility in formating both the code and the resulting output from helpn. comments are welcome. If I run into any problems with this strategy, I will post the issues. So far, it looks workable. Tim