|
From: Ethan M. <merritt@u.washington.edu> - 2007-08-16 16:47:02
|
On Thursday 16 August 2007 05:10, Hans-Bernhard Br=F6ker wrote:
>=20
> Maybe, instead of inventing more new syntax, we should follow=20
> established C syntax
That was the original intent. But I was insufficiently clever at the time;
I could not see how to modify gnuplot's parsing routines to handle the
assignment operator. Now I have stared at the code more intently.
I have updated the patch on SourceForge to implement C-like assignment
syntax. For example,
gnuplot> show at a =3D b =3D c =3D 1
pushc "a"
pushc "b"
pushc "c"
pushc 1
=3D
=3D
=3D
This addition to the expression syntax allows the running sum trick
without any special handling of data column processing:
plot 'foo' using 1:(sum =3D sum + $2)
> implement the comma operator and the "each assignment is an expression, t=
oo"
> idea. E.g. an averaging filter could be expressed as:
>=20
> using 1:(N =3D N + 1, sum =3D sum + $2, sum / N)
Adding the comma operator would be relatively easy, I think.
> And even if we're going to do this, the using specification is not=20
> really the right place to do it in.
I entirely agree. The patches I posted were equivalent to=20
"thinking out loud". I didn't like either of the initial two
implementations. But I find it very useful to have a version that runs
and that approximates the desired functionality so that I can
experiment with what the new feature allows or doesn't allow.=20
Anyhow, the version now on SourceForge is the first to truly capture
the original intent. It adds '=3D' as an assignment operator; all else
follows automatically from that.
It needs to be double-checked for operator precedence, possible
memory leaks, etc. But it is usable for testing as-is.
=2D-=20
Ethan A Merritt
|