|
From: Petr M. <mi...@ph...> - 2004-10-25 13:33:03
|
> > > I though that instead of using
> > > a=`runme`
> > > there would be an alternative with macro expansion:
> > > a=command('runme')
>
> I did figure out how to implement a gnuplot function
> <string-value> = command(<string-expression>)
> but I have serious reservations about it.
> (1) it leaks memory (probably fixable, but so far I haven't
> figured out how)
> (2) it makes me really uneasy that you could trigger evaluation
> of this function from, say, inside a plot statement:
> plot <foo> 1:using (command("something expensive"))
> This could, to say the least, consume system resources.
It could whatever syntax is used, couldn't it?
> So instead I offer the following alternative proposal.
> I have updated the patchset on SourceForge to include the
> following variant syntax
> @"stringvar" evaluates to "contents of stringvar"
> That is, it evaluates the stringvar and places the value in
> double-quotes.
>
> But when back-tics are involved it becomes more interesting.
>
> > I need something like
> >
> > gawkcall = sprintf("gawk -f getname %i %s", this_index, filename)
> > name = execute(gawkcall)
>
> With the new syntax, you would do this as follows:
> gawkcall = sprintf( '` gawk -f getname %i %s `', ...)
> show var
> gawkcall = ` gawk -f getname ... `
> name = @"gawkcall"
>
> Note that the sprintf call uses single-quote + back-tic to delimit
> the command string.
Well, this needs a lot of thinkinkg to understand this syntax, but looks
feasible if enough examples are given in the docs. (BTW, there should be
"help string" and "help quotes" added to gnuplot.doc to easily find them.)
---
PM
|