[SR-Dev] script parsing: string switch support

Henning Westerholt henning.westerholt at 1und1.de
Fri Feb 20 16:06:15 CET 2009


On Friday 20 February 2009, Andrei Pelinescu-Onciul wrote:
> > > This would only make sense if we use match() for strings and switch()
> > > for ints. Otherwise it would be too confusing.
> > > Anyway I don't think the amount of details of the configuration
> > > language is ever a problem, as long as one gets meaningful error
> > > messages when checking the config (and before ser startup).
> >
> > the amount of detail in the config language is IMHO important. The
> > developers must document and test every single statement. Every user must
> > read, learn and memorize each statement too.
> >
> > I regulary need to check the documentation for some special cases in the
> > config when i get asked for a review of some changes a co-worker did,
> > because he still feel not completely confortable after years of
> > administrating SER* systems. During all the time i spend on user channels
> > i really rarely heard the that our server is to slow (only when some real
> > bottlenecks were involved, like DB), the common complain is that the
> > learning curve is too steep. Perhaps i'm lazy, but i'd not say that
> > everybody out there is it too. ;-)
>
> Good luck with runtime debugging then :-)

Ok, perhaps we just trade this problem for another one.. ;-) Anyway, i'm 
really curious about other opinions on this topic.

> > > The other approaches trade-off less config details for guessing what
> > > the user intended, which IMO is much more dangerous. Is much better to
> > > get meaningful errors when running ser -cf ... , then getting
> > > unexpected behaviour at runtime (a very good example for this are typed
> > > variables vs. untyped ones or operators that try to guess the type and
> > > assume the user made the right choice).
> >
> > I just checked in kamailio, we don't throw an error if one mix strings
> > and ints in a switch case. We also check for a correct type of an integer
> > in a mixed expression, e.g. if its a valid int value. I don't think that
> > we convert them implicitly, as many pseudo-variables hold internally both
> > a string and a integer value, so mixed expression will work just as
> > intended in
>
> Sorry, but that's just broken (mixed expressions).

Yes, i also would not recommend it at all. I was even surprised that it 
actually parse the configuration file..

Cheers,

Henning



More information about the sr-dev mailing list