Re: Why is 'else' demanded?
Steven Gordon <[email protected]> Sun, 9 Jun 2013 13:07:31 -0700
| Newsgroups | gmane.comp.programming.refactoring |
|---|---|
| Message-ID | <CAF7qo6WLvFrsaKB5_-8k_QSYoRf0RD0xvhgW0Lzdkva8LdhH5w@mail.gmail.com> |
Sometimes, you want to continue with the next piece of logic after either condition in the if ... else ..., but a return would skip the remainder of the function. Do you also object to case statements, since we can always accomplish the same logic with just ifs and returns? If the criteria for a language is that there always be exactly one way to express anything, then we would end up with a language in which it is difficult to express many common constructs. We might end up writing programs using turing machines or assembly language. That said, one of my projects over the last several years has utilized a language with no "else": Prolog. I do not miss it at all in Prolog. On Sun, Jun 9, 2013 at 12:02 PM, =E5=BC=A0=E7=BA=A2=E4=BA=AE <zhanghonglian= [email protected]> wrote: > ** > > > I have a problem. Why is there always else key word in a language? Since = I > can use return to stop the process of a flow. I hate to see else statemen= t > and I see I can never use else statement that only increase the complexit= y > of program. > > A if statement stands for a condition that should be unique, and it shoul= d > has no relation with anything else. So a language does not need else and = it > should not appear in a program. > > Sent from my iPad >=20=20 > [Non-text portions of this message have been removed] ------------------------------------ Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/refactoring/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/refactoring/join (Yahoo! ID required) <*> To change settings via email: [email protected]=20 [email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/