From: Hans-Bernhard B. <br...@ph...> - 2004-07-22 02:07:19
|
On Wed, 21 Jul 2004, Ethan Merritt wrote: > Let me start with a plea to drop the term "late evaluation", > which I think is side-tracking the current discussion. Objection, on the grounds that a shared understanding of what that term means, and what the relation between that and the string variable/function support you're coding is *exactly* the core of the entire discussion we're (still) having. In a very small nutshell: your patchset, combined adds two things: 1) string variables, expressions and functions 2) late evaluation of a special type of string literals: 'sprintf("%g", x)' as expressions. I fully support 1), but object to 2) in its current shape, for reasons of user interface clarity and future extensibility. Now, the long version of the above: As far as I can see, we all agree upon 1), but somewhere along the way we lost track of what you're doing, and thought 2) was the *only* kind of string expression evaluation you're proposing. Well, at least that what threw me off. So I suggest we take 1) for granted, and concentrate on 2). > Whatever it may mean to different people, I don't think it is > a useful way of thinking about my patchsets. Well, then let me point out what it means (by my understanding, which I do hope is pretty standard): in any language where functions or macros are defined whose final value depend on other variable's values, it's a central design question when to to actually resolve those unknowns into known values and compute the result of the function/macro, i.e. "evaluate" them: at the time the function/macro is defined, or at the time it's value is actually used. The latter case is called "late evaluation". In other words, 'late evaluation' means you store the expression as it was entered, and only substitute values for the variables the moment you need the value. > The evaluation is never "late"; it happens when it happens. That statement makes no sense. If it happens at a later stage than it could have been done at, it is late. Let me show you how this distinction translates into gnuplot: gnuplot> x = 1 gnuplot> y = x gnuplot> a(b)=x gnuplot> print y, a(0) 1 1 gnuplot> x = 2 gnuplot> print y, a(0) 1 2 As you see, a(b) picks up the modified value of x, but y doesn't. That is late evaluation in action. Now, the goal which your 'sprintf() inside quotes' method addresses is that there's currently no way at all to do "even later" evaluation of the parameters that get stored by the various 'set' commands. In other words, the actually stored parameters currently can't be expressions --- they're all fixed values that have been computed from the actual expressions at the time of the 'set' command: gnuplot> set arrow 1 from x, y to x, a(0) gnuplot> show arrow arrow 1, linetype 1, linewidth 1.000 nofilled back from (2, 1, 0) to (2, 2, 0) In the light of this, I hope you can see how the only part about your proposal I really don't agree with is the fact that it introduces late evaluation only for strings. I do agree that late evaluation is a useful tool to add. But I disagree about it being useful for strings _only_. I'm aware that an approach that does this from the outside instead of the inside of string literals will be harder to implement, because it'll have to be done as part of command line parsing, and will have repercussions pretty much all through the program. But I'm stricly opposed to any syntax that can't be applied to numerical late evaluation, too. I think a syntax like later(sprintf("%g", y)) later(x); or, shorter $(sprintf("%g", y)) $(x) would be strongly preferrable, even at the cost of extra work at source level. Since there's nothing one can do with late evaluation that one couldn't also achieve without it (by changing the order of commands, possibly re-loading a saved series of commands), I suggest we keep this part of the patch collection out of the CVS tree and go for a mode broadly scoped implementation of that feature. -- Hans-Bernhard Broeker (br...@ph...) Even if all the snow were burnt, ashes would remain. |