From: Ethan A M. <merritt@u.washington.edu> - 2004-07-18 18:26:17
|
> A more important test case to keep in mind is: > > gnuplot> set xlabel 'single\single' > gnuplot> show xlabel > > xlabel is "single\single", offset at 0.000000, 0.000000 > > Note how the \ from the single-quoted string got doubled. > > Generally speaking I'm not quite sure the syntax you > suggested for that string variables patch is suitable. For > one thing, it breaks the 'single quoted strings are used > as-is without further processing' scheme. This is not something I am suggesting; it is something that is already there, and is broken (IMHO). In practice that rule is 'single quoted strings are not processed when typed on the command line, but are processed later on whenever they are used, or saved'. I consider this a bug, because you do not get the same behaviour from a saved file that you got from the original. I did not change or propose anything new for the string variables patch (yet). I am just pointing out how it already works. It was a happy accident that this bug allowed me to give an example of delayed evaluation, but I still consider it a bug. > In my own > deliberations abotu this, I never intended for the sprintf() > to be *inside* the quotes. Heh. In fact it was your suggestion that made me realize this was possible. You said: > So far, my vague idea was to require string-valued expressions > to always start with a string constant, for its benefit. I.e. we would have > > plot ''+g(p,q) # string --> computed filename I thought this was very clever; all the existing code will continue to recognize it as a string constant, while any new code can peer at the start of the string to see a function evaluation is needed. To make it blindingly obvious what is going on, I used the 7 character string "sprintf" instead of the 1 character string "+" you used in your example. But I already stated that I have no string preference for what this magic string would be, other than it had better be something not normally printed as the start of a string constant. Dave Denholm suggested using tripled-quotes: """ but I don't like that because it looks like an attempt to insert a literal quote mark. Another suggestion from quite a while back was to use the form %(<expr>) to indicate an expression that was to be evaluated at plot time. That could be generalized to: "%(<expr>)" for strings, including "%(sprintf(...))", where in this formulation there is nothing special about the characters "sprintf"; it just happens to be the function that is to be evaluated. -- Ethan A Merritt Department of Biochemistry & Biomolecular Structure Center University of Washington, Seattle |