lout-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: A companion interpreted language for @Filter clause


From: John Gerard Malecki
Subject: RE: A companion interpreted language for @Filter clause
Date: Tue, 18 Jan 2000 03:22:49 +0300 (MSK)

This turned out to be a long email.  Short question -- is it desirable
to change @Filter to "evaluate" its argument?

Giovanni Zezza writes:
> @Filter is no doubt a powerful and sometimes very useful thing; a sort of
> shortcut to everywhere, so to say. It leads, though, to incompatibility
> problems and, from there, to pure nightmare if overused.

Let me describe one of my uses of lout -- data visualization.  I would
then like to have a variety of lout files which display the data in
different formats.  Instead of spending a lot of time having my
scientific programs format data i would prefer t simply dump the data
and have a separate program format the results.

For example, I would like my data generating program to output a file
of lout definitions such as

        def SNM {"0.58442052082569"}

It can also output vectors on info writing

        def Data {
        "0.0 1.7999999523163"
        "0.0010000000474975 1.7999994754791"
        "0.0020000000949949 1.7999994754791"
        ...}

It is quite easy to dump this info from almost any programming
language.  The data is dumped "raw" without any concern for precision
or format.

Now we want to make multiple views of the data.  For example, i'd like
a short tabular report with 2 digits of precision.  From the same data
i'd like to make a detailed report with graphs and 3 digits of
precision.  All i do is document the names of the data sets i emit and
let my users write lout programs that view the data however they like.

For example, someone may write

        @Include{"data.lout"}
        The value of "SNM" is SNM volts.

which works beautifully but the results are ugly as it becomes

        The value of SNM is 0.58442052082569 volts.

I hacked up a script called fmt to use with @filter.  Fmt is

        #!/bin/sh
        for i in `cat -`; do
            printf $* $i
            done

This works with something like

        def @Fmt
            left format
            right value
        {
          def @Filter { "./fmt" format @FilterIn ">" @FilterOut }
          value
        }

        @Include{"data.lout"}
        The value of "SNM" is "'%0.3f'" @Fmt {0.58442052082569} volts.

And now this produces

        The value of SNM is 0.584 volts.

I thought i could use this to clean up all my numbers.  Unfortunately
@Filter does not evaluate its arguments.  This means that

        The value of "SNM" is "'%0.3f'" @Fmt {SNM} volts.
        
fails as fmt is passed the string SNM and not the "0.58442052082569".
(I tried making SNM a macro but that didn't help.)

As an experiment I hacked the code for @Plus to make it work as a
builtin @Fmt.  This worked well, especially as @Plus evaluates its
argument.  It seems like a bit of work to add a new primitive and I'm
not sure i want to do this with each new release.

Does anyone have a better solution?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]