|
From: Ethan M. <merritt@u.washington.edu> - 2009-11-11 02:12:49
|
On Tuesday 10 November 2009, Philipp K. Janert wrote:
> > 1) The syntax
> > stats data using 20 variable="col20"
> > did not do at all what I expected. I expected to get variables
> > col20_max_x and so on,
> > but what I actually got was variables with embedded quote marks:
> > "col20"max_x
> > Trying to embed this in a plot command was a pain.
>
> The quotes are your addition. We don't expect them,
> but we don't actively remove them. Maybe we should -
> I admit that there is a user expectation that "there should
> be quotes".
Since 4.0 we support string variables. That means wherever a string
is required in the input command, it is acceptable to provide
a string constant, a string variable, or a string-valued function.
So
A = "mydata"
stats "file.dat" using 1 variable=A
must expand A to find "mydata", not use it as an unmarked constant.
All strings should be parsed using the routine try_to_get_string(),
which handles the three cases.
Also, normal commands do not use = signs.
So the source code should be something like:
char *prefix= NULL;
if (equals(c_token,"variable")) {
c_token++;
prefix = try_to_get_string();
}
> > 2) Here's the command I want to issue in the end:
> >
> > plot for [col=5:20] data using (column(4)) : \
> > column(col) / statmax(col))
> >
> > It doesn't work, because I can't figure out how to define a function
> > statmax(col) that retrieves the desired value. We don't have a user-level
> > command in gnuplot that will retrieve the value of a gnuplot variable by
> > its string name. Yesterday I had to forego the iterator and type in a
> > 16-line plot command instead.
>
> If I see this correctly, mostly you would like to add
> support for iteration into the stats command? This
> is certainly something we can think about.
Iteration is a major reason. But the same problem arises whenever you
have constructed the variable name via a script. How do you insert the
value of that variable back into another command?
> >
> > So I want to request a different mechanism for storing and retrieving the
> > stats values. You've seen this before, but here it comes again:
> > I don't want dozens of variables to be created by every stats command,
> > because they are too hard to retrieve inside a script. Instead I want each
> > stats command to load a structure, and I want a set of functions that
> > retrieve the previously calculated stats values, indexed by name. If you
> > want to load a named variable from one of the stats values, fine. Just say
> > Run5_xmin = statmin("Run5")
> > That will persist across a save/load sequence, for instance, even though
> > the internal stats structures will not.
>
> Why is that goodness? I don't understand the
> motivation here.
I thought this was something you wanted. You said gnuplot should not
become statefull, which I take to mean that save/load should get you
back to where you were without having to replay the whole history of
commands.
> Why do you want to go the
> roundabout way (and force the user through
> this detour) of accessing variables through
> functions, rather than as variables?
Because, as I noted above, you cannot currently access their value
by name in a script. I agree there are other possible solutions to
the problem.
|