RE: [PHP] A really wacky design decision

2009-10-06 Thread Andrea Giammarchi
> but is implicitly converted into strings when it is entered. use floatVal($str1) === floatVal($str2) then ... I honestly cannot spot any problem in what you wanna do, I can just spot an error in the root of the process: threat strings as numbers, comparing potatoes and tomatoes ... there a

Re: [PHP] A really wacky design decision

2009-10-05 Thread clancy_1
On Sun, 4 Oct 2009 14:52:36 +0200, an_...@hotmail.com (Andrea Giammarchi) wrote: > > > >> $a = 2260; $b = 226e1; $c = 2.26e3; $d = 2260.0; >> >> $a==$b==$c==$d, >> >> and >> $b===$c===$d > >$b , $c, and $d are the same indeed ... they represent the floating point >2260.0 in I thi

Re: [PHP] A really wacky design decision

2009-10-04 Thread Tom Worster
On 10/4/09 6:36 AM, "clanc...@cybec.com.au" wrote: >> i might think it ok for (2260 == '226E1') to be true since php would be >> doing type juggling in a logical left-to-right manner: we start with an >> integer 2260, next is the juggling comparison operator, then a string, so it >> might reasona

RE: [PHP] A really wacky design decision

2009-10-04 Thread Andrea Giammarchi
> All very messy! there is nothing messy, the logic is well defined and for a loose type language it's absolutely normal behavior. Regards _ Keep your friends updated—even when you’re no

RE: [PHP] A really wacky design decision

2009-10-04 Thread Andrea Giammarchi
> $a = 2260; $b = 226e1; $c = 2.26e3; $d = 2260.0; > > $a==$b==$c==$d, > > and > $b===$c===$d $b , $c, and $d are the same indeed ... they represent the floating point 2260.0 in I think every language ... it's like saying that 1.0 is not 1. ... both floating point numb

Re: [PHP] A really wacky design decision

2009-10-04 Thread clancy_1
On Sat, 03 Oct 2009 11:57:36 -0400, f...@thefsb.org (Tom Worster) wrote: >On 10/3/09 7:21 AM, "clanc...@cybec.com.au" wrote: > >> However there is one feature of PHP which, to my mind, is really bad design. >> How many of >> you can see anything wrong with the following procedure to search a list

Re: [PHP] A really wacky design decision

2009-10-04 Thread clancy_1
I am well aware of the === operator, but I had an uneasy feeling that there was still a trap. However when I tried it it worked, so I was going to thank you for your suggestion, though I find the concept of having separate 'sort of equal' and 'truly equal' operators decidedly distasteful, but t

Re: [PHP] A really wacky design decision

2009-10-03 Thread tedd
At 1:37 PM -0400 10/3/09, Robert Cummings wrote: tedd wrote: At 9:21 PM +1000 10/3/09, clanc...@cybec.com.au wrote: Daevid Vincent is surprised that: $num = 123; $num = $num++; print $num; //this prints 123 and not 124 ?!! I can understand why someone might think this is not correct, but t

RE: [PHP] A really wacky design decision

2009-10-03 Thread Andrea Giammarchi
You introduced the word "suddenly", it's about 10 years I develop in PHP Regards > PHP allows you to do either. If I find myself being more strict in no > way does that mean I'll suddenly jump to another language. It just means > I have a bit of code that requires a bit more strictness. Shoul

Re: [PHP] A really wacky design decision

2009-10-03 Thread Robert Cummings
Andrea Giammarchi wrote: If you use APD or you think about the low level logic behind comparing string, > num and bool you'll probably forget the "==" operator and you'll never miss > again the "===" one ... then you'll start to explicit cast everything, when > necessary, to have all your code

RE: [PHP] A really wacky design decision

2009-10-03 Thread Andrea Giammarchi
if we compare via "==" there is an implicit cast to the most primitive form. These are all true, and all have a reason, and make sense: // (int)'abc' is 0 var_dump('abc' == 0); // 'abc' is not an empty string var_dump('abc' == true); // 2 is not 0, which would be casted into false, so it's tru

Re: [PHP] A really wacky design decision

2009-10-03 Thread Robert Cummings
Tom Worster wrote: On 10/3/09 12:25 PM, "Ashley Sheridan" wrote: On Sat, 2009-10-03 at 11:57 -0400, Tom Worster wrote: On 10/3/09 7:21 AM, "clanc...@cybec.com.au" wrote: However there is one feature of PHP which, to my mind, is really bad design. How many of you can see anything wrong wit

Re: [PHP] A really wacky design decision

2009-10-03 Thread Tom Worster
On 10/3/09 12:25 PM, "Ashley Sheridan" wrote: > On Sat, 2009-10-03 at 11:57 -0400, Tom Worster wrote: > >> On 10/3/09 7:21 AM, "clanc...@cybec.com.au" wrote: >> >>> However there is one feature of PHP which, to my mind, is really bad design. >>> How many of >>> you can see anything wrong with

Re: [PHP] A really wacky design decision

2009-10-03 Thread Robert Cummings
tedd wrote: At 9:21 PM +1000 10/3/09, clanc...@cybec.com.au wrote: Daevid Vincent is surprised that: $num = 123; $num = $num++; print $num; //this prints 123 and not 124 ?!! I can understand why someone might think this is not correct, but they need to understand what is happening and why

Re: [PHP] A really wacky design decision

2009-10-03 Thread Ashley Sheridan
On Sat, 2009-10-03 at 11:57 -0400, Tom Worster wrote: > On 10/3/09 7:21 AM, "clanc...@cybec.com.au" wrote: > > > However there is one feature of PHP which, to my mind, is really bad design. > > How many of > > you can see anything wrong with the following procedure to search a list of > > names

Re: [PHP] A really wacky design decision

2009-10-03 Thread Tom Worster
On 10/3/09 7:21 AM, "clanc...@cybec.com.au" wrote: > However there is one feature of PHP which, to my mind, is really bad design. > How many of > you can see anything wrong with the following procedure to search a list of > names for a > particular name? > > $i = 0; $j = count ($names); while ($

Re: [PHP] A really wacky design decision

2009-10-03 Thread tedd
At 9:21 PM +1000 10/3/09, clanc...@cybec.com.au wrote: Daevid Vincent is surprised that: $num = 123; $num = $num++; print $num; //this prints 123 and not 124 ?!! I can understand why someone might think this is not correct, but they need to understand what is happening and why the above seco

RE: [PHP] A really wacky design decision

2009-10-03 Thread Andrea Giammarchi
And then you discover === $i = 0; $j = count ($names); while ($i < $j) { if ($names[$i] === $target) { break; } ++$i; } ... regards > To: php-general@lists.php.net > From: clanc...@cybec.com.au > Date: Sat, 3 Oct 2009 21:21:00 +1000 > Subject: [PHP] A really wacky design decision > > D