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

Re: N-way system (was Re: Offer of help)



> > AFIW your "get_var" is my "parser" and your "set_var" is my "generator".
> 
> get_var and set_var are the interfaces to the database. They don't
> know about type or contents of a variable, they just know how to store 
> it to the packages conffile or read from it.

No, they are not interfaces to the database  because in your model there is
no database. You say that you use the config files as a database. However,
that is not a real database because it lacks the two most basic features
of a database: fields and indexing. The set of config files is a given dataset
with no freedom at all to introduce new variables or to group them in any
way we might find suitable. There is no logical coherence between the data
and no common format. Any tool that mainipulates the dataset must be an
"ad hoc" tool specifically constructed for each file in the dataset.

What get_var and set_var really are is translators. They translate the
"ad hoc" format of a config file to a format ready for consumption by bash
scripts and vice versa. This translation is what is called parsing/generating,
depending on the direction of the translation.

[...]

> Most programs have a more complicated conffile and then the templates
> get realy ugly and without the ability to extract variables from an
> existing or user modified conffile the tool is worthless, it would do
> more harm than good. So you need a get_var interface anyway (which
> could be template generated :) and a set_var is then trivial (which
> could also be template generated).

If the conffile is complicated, then any solution will be ugly. That's a fact.
However, I think templates will be the least ugly solution.

I disagree about the worthlessness of templates. In many cases, you do not
want to keep your old values. For example, if you change your domain name,
you want all references to your old domain name to change to your new domain
name without having to change them one by one. You might not even know in how
many config files they appear. That's something that templates solve trivially.

You might have changed your type of connection from modem to ethernet and
want to regenerate all config files with the new setup. Or you might have
changed the way your mail is delivered, or even your motherboard, and now
have a PS/2 mouse instead of a serial one. And you want those changes to
propagate to all pertinent config files without having to change them one
by one. In all these cases, templates make your life easier.

And having templates does not prevent us from having parsers too. You can have
both, that is the eventual goal. But having one is still better than having
none.

> Anything short of lex/yacc parsing will be insufficient at some
> time. I don't think restricting the syntax of conffiles below lex/yacc 
> level would be good.
> 

That might or might not be true. I am unconvinced yet.

> > You seem to believe that the difficulty involved in writing get_var is the
> > same as in writing set_var. However, this is far from being true. The
> > complexity of get_var is much much higher than that of set_var. That is why
> > two-way systems are so rare.
> 
> The few get_var/set_var functions I've written for testing purposes of 
> my proposal seem to be very similar. If you have one of them done, the 
> other one is easy. Actually writing set_var seems more difficult,
> since you have to try to keep alignment and extra spaces in place to
> keep the conffiles nice looking and you have to insert variables at
> the right places, which get_var goes along wiht some greps and cuts.

This contradicts with your statement above that anything short of lex/yacc
will be insufficient. If you can do the parsing by grep and cut alone, then
that means that the grammar is much simpler than a LALR(1) grammar.
Therefore, either you chose trivial examples or a simpler parsing tool is
possible.

About set_var being more difficult, I find it surprising. Using templates,
set_var is usually trivial. All the alignment and extra spaces is just
copied from the template with 0 effort from the developer.

> If get_var is a problem to write, one can allways just copy the parts
> from the source that read the conffile.

Ugh. _That_ is ugly. You know that copy+paste almost never works. A lot,
really a lot of massaging is necessary to adapt the code. That might be
asking too much to maintainers.

Fernando



Reply to: