[SR-Users] how can string "0" be equal to int 0?

Andrei Pelinescu-Onciul andrei at iptel.org
Fri Oct 15 17:14:09 CEST 2010


On Oct 15, 2010 at 17:04, Daniel-Constantin Mierla <miconda at gmail.com> wrote:
> 
> 
> On 10/15/10 4:36 PM, Andrei Pelinescu-Onciul wrote:
> >On Oct 15, 2010 at 16:26, Daniel-Constantin Mierla<miconda at gmail.com>  wrote:
> >>
> >>On 10/15/10 1:43 PM, Juha Heinanen wrote:
> >>>Daniel-Constantin Mierla writes:
> >>>
> >>>>I don't think a strict type checking is suitable for configuration file
> >>>>- e.g., if I want to check value in cseq, don't want to get lost in type
> >>>>conversions.
> >>>>
> >>>>If there is going to be such error messages, they must be enclosed in a
> >>>>config parameter.
> >>>yes, there could be a config parameter
> >>>"warn_about_implicit_type_conversions" or something like that.  i would
> >>>definitely turn it on, since it would not be a big deal for me to add
> >>>(int) or (string) in front of a variable when i want type conversion to
> >>>be done in order to avoid config mistakes that get unnoticed.
> >>
> >>At the end of the day, one can write entire routing logic directly
> >>in C code.
> >>
> >>Config language is complex enough, adding such things to it will
> >>make it really unusable. Bear in mind that config is for sys admins
> >>not for programmers. They operate the platform, then should care
> >>only of SIP layer (which is alone difficult enough), not typed of
> >>variables and heavy programming languages.
> >>
> >>Btw, what mistakes really can happen? That string "0" is equal with
> >>0? It is this way for so many years now.
> >>
> >>Either we focus to make the config file easier to understand and
> >>use, or drop it and tell everything has to be written in C and the
> >>50-100 of us, developers, will use it.
> >Actually there is a more dangerous thing here. All this nice features
> >might hide script errors up to runtime. With a more strict type checking
> >(and different operators for ints and strings), much more checking can
> >be done at startup. In my opinion this would be more user friendly, then
> >allowing everything and try to guess at runtime what the user really
> >wanted. It's much more important to make sure the script is ok before
> >starting, then to save someone some typing.
> >
> >Regarding this case, I agree that changing it now for 3.1 is a bad idea
> >and this is also not the best example of how things could go wrong.
> >
> Andrei,
> 
> besides that bad things can happen always :-) , so far nobody
> complained about such cases, but about complexity to understand and
> build configuration files.
> 
> If we make it more C like, for sure won't get new people or
> businesses jumping in. Paying a programmer for sysadmin job won't
> work, maybe not only because of money, but because of people's own
> expectation. And perhaps is were we get in the trap, we are
> programmers and we would like to be same, but as said in the
> previous email, we end up to close a circle of 50-100 people.

So it's better to have hidden errors in script that are quite difficult
to find, rather then forcing people to use a variable type?
Most non-programmer people will use strings anyway and they wouldn't be
affected by this.
For me when it comes to production servers any extra config checks it's
worth the formidable effort to remember to use a different operator for
integers and to declare variable that are supposed to hold integers.

> 
> From the first time avps were introduced that they can hold string
> or integers. xlog introduced specifiers holding all the time strings
> and later used for pseudo-variables, that is more than 5 years ago
> and all went fine so far.
> 
> Changing current behavior will be killing, using new operators
> (iirc, you added something with le, lt, ...) would be an option, but
> we add more to the confusion of what and how to use.


Andrei



More information about the sr-users mailing list