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

Andrei Pelinescu-Onciul andrei at iptel.org
Fri Oct 15 16:36:50 CEST 2010


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



More information about the sr-users mailing list