From: Hans-Bernhard B. <br...@ph...> - 2004-07-18 14:03:48
|
On Sat, 17 Jul 2004, Ethan A Merritt wrote: > Anyhow, adding additional string-valued functions would be very easy. > Let's discuss which ones might be desirable. > > 1) gprintf("format",mantissa,exponent) > Is that the form it should take? No. It should be gprintf("format", number). The crucial difference is that C's sprintf() supports multiple % formats and uses up exactly one argument per format specifier, whereas gprintf() only ever has one argument, but may use more than one format specifier with it. The syntax of my stop-gap extension to 'set lable' looks the way it does for a reason: set label 'a = %l * 10^{%L}', a, ', length = %s %cm', length \ at 2,3 > 2) Some way to do arithmetic using numerical values stored in > a string. E.g. > a = "1.2" > b = 3.4 > c = a+b > It would be straightforward, although tedious, to modify every > existing atomic evaluation routine in internal.c so that it > recognizes string-values during arithmetic. They would be > converted to (double) using atof(). But is this at all necessary? I don't think so. I think we should follow a Java-like approach: adding a number to a string converts the number to a string and concatenates. The only way to get a number back from a string would be by explicit function call. > 3) user-defined string-valued functions. > I don't see at the moment how to implement these, although > I think it would be possible. Are they needed? I think they are. Users will almost certainly want to be able to do something like this: filename(i)=sprintf("foobar%d.ps", i) i=15 # in a loaded file: set output filename(i) plot something i=i+1 reread > 4) Do we want any string operations besides concatenation? > Substrings? String comparison? Yes, yes, and possibly, in that order. -- Hans-Bernhard Broeker (br...@ph...) Even if all the snow were burnt, ashes would remain. |