[sr-dev] another syntax error

Andrei Pelinescu-Onciul andrei at iptel.org
Wed Jun 3 19:06:29 CEST 2009


On Jun 01, 2009 at 19:27, Juha Heinanen <jh at tutpro.com> wrote:
> Andrei Pelinescu-Onciul writes:
> 
>  > If you mean defined ($fU), instead of defined $fU, I prefer defined $fU
>  >  (is more perl-like) and defined ($fU) or defined($fU) works anyway.
> 
> great, i tested and also defined($fU) works!
> 
>  > > this i don't understand.  if i assign $something = "", then $something
>  > > is defined and test defined $something should return true.
>  > 
>  > == is for comparisons not for assignment. If I compare an undefined
>  > value with "" in most languages is true.
> 
> empty string "" is a very well defined string value.  it has nothing to
> do with UNDEFINED.  i could accept that it would be consider FALSE in a
> test, but not UNDEFINED.

Think of it as automatic conversion.
> 
> regarding "most languages", perhaps perl is such, but even in php, ""
> value is a defined (set) value:
> 
> $var = '';
> 
> // This will evaluate to TRUE so the text will be printed.
> if (isset($var)) {
>     echo "This var is set so I will print.";
> }

This will evaluate to TRUE also in sip-router (if (defined($var))).
The question is how is if ($foo == "") evaluated when $foo is
undefined in php.

> 
> how do we solve this problem?  cast a vote or what?

Why would you want sip-router to behave differently then other scripting
languages?
I agree that comparing with undefined is and undefined operation so any
solution is more a matter of convention then logic (from a strictly
logical point of view it should throw an error), but since the
convention and what most people expect is that comparing and undefined
value to "" should return TRUE, why innovate?


Andrei



More information about the sr-dev mailing list