Re: IF or SWITCH
| From: | Ray Hauge | Date: | Thu, 06 Apr 2006 21:07:34 +0000 |
| Subject: | Re: IF or SWITCH | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-233406@lists.php.net to get a copy of this message | ||
On Thursday 06 April 2006 11:20, tedd wrote:
> At 1:04 PM -0400 4/6/06, Robert Cummings wrote:
> >On Thu, 2006-04-06 at 11:50, tedd wrote:
> >> Regardless of speed, I find that switch is much easier to write and
> >> debug than if/elseif -- which, regardless of my shortcomings, I never
> >> use.
> >
> >Umm, that you NEVER use elseif I think is strongly coupled with your
> >shortcomings :l But I'm not judging, to each his own :|
> >
> >Cheers,
> >Rob.
>
> Rob:
>
> Yes NEVER -- as for my shortcomings, they remain as obvious as is my
> lack of pretense otherwise. Whereas, my abilities, like most, are not
> as obvious. As Will Roger's once said "We're all ignorant, only in
> different subjects."
>
> But regardless of my limitations, I still have never had to use an
> if/elseif for anything -- and I wrote my first line of code in 1966.
> I don't remember specifically just when if/elseif and switch-like
> conditionals first appeared in programming (they haven't always been
> there and my old Fortran books have been long stored) but I have one
> in front of me that's dated 1976 where it just mentions "The Logical
> IF Statement" with no if/else or switch-like statements.
>
> So, my programming probably predates both conditions -- however -- in
> 40 years I have NEVER used an if/elseif control structure by any name
> and I always found a way around it -- and one that was usually faster
> and with better readability.
>
> If your strong-comings are better than my shortcomings, then perhaps
> you could provide an example of where a switch could not preform what
> an if/elseif could -- do you have one?
>
> My gut feeling is that you can't -- as well as my gut feeling that
> when language developers first thought of if/elseif control, they
> realized that it was confusing and provided a switch to get around
> it. But, then again, maybe I'm wrong -- been there before. :-)
>
> tedd
> --
> ---------------------------------------------------------------------------
>----- http://sperling.com
I'm pretty sure he's ONLY talking about IF/ELSEIF and not IF in general.
That's what I got from the message. Correct me if I'm wrong.
I ended up deciding to stay with the IF/ELSEIF statements... mostly because I
was already done. I did clean up the COUNT()ing though.
Always nice when the list helps out :)
--
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099