From: Oren Ben-K. <or...@ri...> - 2002-05-21 14:11:14
|
Brian Ingerson [mailto:in...@tt...] wrote: > I think we're missing the whole point of what I really want here. > Clark alluded to it but, what I really want is the ability to extend > the multiline leaf formats that we support. One very useful format > would be a mix of block and folded. Lines beginning with whitespace > (as content) would be block. Lines beginning with non-whitespace would > be folded. I see this pattern in textual data all the time. (If you > know Perl, think POD) Hmmm. Even if you make this a format, extending it won't be trivial (it effects parsers/loaders everywhere). And IMVHO str is too basic a type to extend it like that later on. > Anyway, we'll probably want to extend our multiline styles. I, for one, would be happy if we could have *less* styles. The trouble is, I see the sense in all our three variables (chomping, folding and escaping). > I proposed > to Clark that 'folded' was merely another string format like 'mixed'. > Everything could be specified using our current block format with some > kind of format or style modifier. And the reformatting would > be done at the Loader level, not by the Parser. That means that we can only apply these formats to !str. On the up side, it means that we would have just one "style" of multi-line scalars (block). For type families such as binary, it is easy enough to specify that all white space is ignored. I said this is a show stopper before, but if there's a real advantage in doing this... Let's see: this: !str|folded Is horribly verbose! Possible solution: How about we allow !|<format> as a shorthand for !<implicit>|<format> (or at least as a shorthand for !str|<format>)? this: !|-\) # type: 'str' format: '|-\)' Folded ')', chomped '-', escaped '\\'. This would move all the escaping/folding/chomping code to the string loader code (and its description to the transfer method section - Eeek!), using named formats (empty/default format : block, - : chomped, \ : escaped, ) or > or ^ or ] or whatever : folded, and their combinations.) Hmmm. This just trades off one special mechanism by another, and reduces the power (since it becomes impossible to use, say, escaped format for non-!str types). I don't know. I think at this point I'd basically keep things as they are, unless someone comes up with a distinct advantage in doing things differently. Notation wise, I agree it makes sense to make the folded indicator a modifier for the multi-line indicator. Ans we agree about using '-' for chomped and '\' for escaped. This leaves us with two characters - one for the block indicator (currently |) and one for the folded indicator (currently ]). What character pair should be used (| or ; for multi-line and ), ], > or ^ for folded) is just a matter of taste. I'll leave the decision to Clark. My personal choice would be to keep things as they are (| for block, ] for folded). Whatever we choose, I think it is vital that the following combinations would have terse, clear notation: Block: | Seems clean enough Folded: |] Clearer than today's standalone ] Escaped folded: |\] Not too bad. I think these would cover most of the actual uses. > How about: > > --- <multi style="mixed" chomp="no"> Shudder :-) Have fun, Oren Ben-Kiki |