As I have tried to explain concerning TeX during IWP9, TeX is only C89
and I want it to behave exactly the same whatever the hosting OS is.
Because if joe user uses TeX, if it behaves exactly the same on
whatever OS, there is no impossibility to swap the OS underneath.

While thinking about the way an interactive session with TeX works,
I'm currently thinking about the line editing feature---not a big
problem, because TeX calls a C89 routine to get the next line, and the
editing is the "spoon" before entering the "mouth" i.e. it is outside
TeX altogether.

But I was thinking about also of a way to behave more helpfully about
macros: since the macros are digested, TeX knows what is their syntax,
what is the type of arguments and so on, so could display an help
about the usage (this has to be done in TeX proper) and there could be
a better editing of incorrect arguments in an interactive session.

But this is TeX internals. The question about the usage and the
interactive editing of arguments (and the correction of partially
incorrect arguments) could be done also more generally with any
utility, including, depending on the terminal, using different
arguments handling.

There is prior partial art: limited getopt(3) on Unix; a more general
handling routine in C.E.R.L. GRASS that takes the argc and argv[],
verifying type of argument, range, setting default values and engaging,
if interactive, a dialog with the user whether to get the mandatory
arguments if not provided or to correct the incorrect ones.

In pseudo C, a utility (an equivalent can be made for a rc script)
would set an array of this:

typedef struct {
        int cat;
#define PARM_CAT_EOP    0       /* final sentry of array */
#define PARM_CAT_FLAG   0x01    /* "-h" like */
#define PARM_CAT_OPTION 0x02    /* "skip=val" like */
#define PARM_CAT_ARG    0x04    /* positional arg */    

        char *name;     /* positional is "[1-9][0-9]*" or "*" for "wherever" */
                        /* positional is not counting flags and options */
        int flags;
#define PARM_FLAG_MANDATORY     0x01
#define PARM_FLAG_MULTIPLE      0x02    /* a list of values of type */

        int type;
#define PARM_TYPE_STRING        0
#define PARM_TYPE_INT           1
#define PARM_TYPE_FLOAT         2
#define PARM_TYPE_PATH          3

        char *range;    /* acceptable range of values for numbers */
                        /* a regex for strings and paths */
        /* for following require and forbid, index of PARM_CAT_EOP is
          end of array
         */
        int *require;   /* an array of indices of parms required with */
        int *forbid;    /* an array of indices of conflicting parms */
        char *default;
        char *description;
        /* these are filled in return */
        int nval;       /* count of values */
        char **val;
} Parm;

Depending on what server is attached for serving arguments, if none,
the syntax is verified as well as the ranges, the defaults being
set, and it exits on error sending usage on stderr without modifying
the arguments served.

A line oriented server could engage a dialog with the user to correct
arguments or to ask for missing arguments.

A 2D oriented server could do this by displaying a graphical interface
to get the arguments if not provided or incorrectly provided.

The three principal ideas being:

1) that a utility has the information about what arguments it
expects so say that an extension of the Unix like "tab-completion" after
a utility name would display the usage, because it is served from
inside the utility;

2) that such a description can provide immediately an usage without
having to write the code, and that the handling of ranges, types and so
on have not to be repeated in every utility;

3) that a graphical interface is just another way of getting arguments,
and there should be no necessity to program a special version of a
utility to change the way the arguments are provided.

Is such an idea totally orthogonal to Plan9?
-- 
        Thierry Laronde <tlaronde +AT+ kergis +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Tc934d74ee389ad6a-M58c70eafe8e0a67816e6247c
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to