|
From: Ethan A M. <sf...@us...> - 2014-10-29 20:28:17
|
On Wednesday, 29 October, 2014 11:59:44 Philipp K. Janert wrote: > > Just a question/suggestion... > > I am trying to understand the proper use of the > new "heredoc" feature. > > Ethan pointed out (on gp-info) that it is usually > used as part of a command script. That makes me > wonder whether the contents of a heredoc should be > included in the information that is written to file > using "save". > > My rationale is this: traditionally, "save" > persisted the entire session state (excluding > terminal settings). Loading the resulting file > with "load" recreated the entire session, even > if gnuplot had been exited and restarted in the > meantime. > > Now I imagine an interactive session, in which > I define a heredoc (to add some points to a graph, > for example). Now doing a "save", exit, and "load" > will NOT recreate the session, in fact the "load" > will fail, since the data block (=heredoc) is no > longer defined! I suppose that's one way of thinking about it, but it's not the viewpoint that motivated heredoc originally. I view it as a mechanism to avoid requiring multiple files associated with a reusable script. It is an alternate data source, not part of the session state. "save" doesn't include the content of the last data file plotted, and it doesn't include the content of the last heredoc plotted. If you had used in-line data via plot '-' then it wouldn't save that either. > I think it is undesirable that a command file > generated by "save" will fail to "load". Moreover, > I strongly think that "re-creatibility" of a plot > is an essential feature. But currently, plots > involving interactively defined heredocs are not > recreateable. That's exactly backwards to the way I see it. If a script requires a separate auxilliary data file to run, that introduces an extra dependency for reproducing any plot created by that script. By instead placing the data in a heredoc in the script itself, the plot can be recreated without tracking down an additional data file. > More broadly speaking, I am wondering about the > strategic intent/direction for heredocs. For > instance, I would expect to be able to load a > data file into a heredoc "variable", so that I > then don't have to touch the underlying file again. > Currently, their primary purpose seems to be to > embed data in command (demo?) files - which is > not exactly a feature most users need every day. Think of a data analysis script that takes as input a data file and produces a plot of the experimental data vs a reference curve. If the reference curve is easily generated by an analytic function then probably you'd use that. But if the reference curve itself is defined by observed data then either you need to provide a separate reference data file or place the reference data in a heredoc. Placing it in a heredoc makes the script self-contained. For this type of application, "save" is not a normal command. If you want to regenerate a plot you just run the script again. Ethan |