[SR-Users] Consistency: -1 sometimes true, sometimes false

Daniel-Constantin Mierla miconda at gmail.com
Wed Aug 23 15:07:55 CEST 2017


Hello,


On 23.08.17 10:36, Alex Balashov wrote:
> On Wed, Aug 23, 2017 at 10:34:03AM +0200, Sebastian Damm wrote:
>
>> Well, I printed out the content of the variable while debugging and it
>> carried 1 or -1 depending on the outcome of allow_address(), so this
>> basically seems to work.
> Fair enough. Then it really is a case of evaluation rules being
> different for variables than for inline function calls.
>
this kind of inconsistency it's a bag that had to be carried over the
time due to initial version of the scripting language back in 2001-2002
when it was decided how to evaluate the return codes for
functions/routing blocks. At that moment there were no config variables,
so it was considered to make it simple with:

  - evaluate negative return to false
  - evaluate 0 (zero) return to 'exit'
  - evaluate positive return to true

Starting with year like 2004-2005, with the addition of the variables,
they were evaluated as integer numbers, more or less like in C. Boolean
variables are not defined for config, so it is better (and more
explicit) to evaluate PVs values against numbers.

In short: boolean evaluation of a return code for a function is done
differently that the evaluation of returned value by a variable.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - www.asipto.com
Kamailio World Conference - www.kamailioworld.com




More information about the sr-users mailing list