Re: Why is 'else' demanded?
张红亮 <[email protected]> Mon, 10 Jun 2013 15:24:21 +0800
| Newsgroups | gmane.comp.programming.refactoring,gmane.spam.detected |
|---|---|
| Message-ID | <[email protected]> |
You are right, I am bigoted too much. I also meant it is some harder to tra= nsform all conditional statements into a direct flow. I spent a lot of time= transforming so I am confused to do that. It is better to do that when nec= essary, I.e.=20 Replace Nested Conditional with Guard Clauses It is listed a refactor method in Martin Fowler's book. Thank your reply. I learn a lot from your answer. Best regards. =E5=BC=A0=E7=BA=A2=E4=BA=AE ZhangHong-liang M:18640223030 DL: 010=EF=BC=8D82870058 =E4=B8=8A=E6=B5=B7=E9=9B=B7=E8=85=BE=E8=BD=AF=E4=BB=B6=E6=9C=89=E9=99=90=E5= =85=AC=E5=8F=B8 ShangHai raxtone software limited company =E5=8C=97=E4=BA=AC=E5=B8=82=E6=B5=B7=E6=B7=80=E5=8C=BA=E4=B8=AD=E5=85=B3=E6= =9D=91=E5=BD=A9=E5=92=8C=E5=9D=8A=E8=B7=AF11=E5=8F=B7=E5=8D=8E=E4=B8=80=E6= =8E=A7=E8=82=A1=E5=A4=A7=E5=8E=A6201=E5=AE=A4 201 room HuaYi holding mansion ZhongGuan village CaiHeFang road HaiDian di= strict BeiJing Fax:82870098 On 2013-6-10, at 4:07, Steven Gordon <[email protected]> wrote: > 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 o= f > the function. >=20 > Do you also object to case statements, since we can always accomplish the > same logic with just ifs and returns? >=20 > 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. >=20 > 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. >=20 > On Sun, Jun 9, 2013 at 12:02 PM, =E5=BC=A0=E7=BA=A2=E4=BA=AE <zhanghongli= [email protected]> wrote: >=20 > > ** > > > > > > I have a problem. Why is there always else key word in a language? Sinc= e I > > can use return to stop the process of a flow. I hate to see else statem= ent > > and I see I can never use else statement that only increase the complex= ity > > of program. > > > > A if statement stands for a condition that should be unique, and it sho= uld > > has no relation with anything else. So a language does not need else an= d it > > should not appear in a program. > > > > Sent from my iPad > >=20 > > >=20 > [Non-text portions of this message have been removed] >=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/