From: Stefan Kaes Date: 2005-11-22T17:10:32+09:00 Subject: Re: semenatics of if/unless/while statement modifiers Yukihiro Matsumoto wrote: >Hi, > >In message "Re: semenatics of if/unless/while statement modifiers" > on Tue, 22 Nov 2005 16:49:20 +0900, Stefan Kaes writes: > >|Most language constructs can be abused by programmers to write >|unreadable code. For example, the following is valid Ruby code: >| >|def foo(x); "..."; end >| >|some_value = foo( >| begin >| x = 721 >| y = 100 >| while x>y >| x /= (i= 17; while i>0 >| i -= 1 >| end) >| end >| rescue >| puts "something strange happened" >| 0 >| end >| ) >|puts foo(3).to_s >| >|And yet you don't ban complex expressions inside function call arguments >|or on the RHS of an assignment, although they can be used to write >|pretty unreadable code. > >It's complex, but it's not harder to read than it really is, just >because it's natural application of syntax rules. I feel like >altering local variable rule sometimes make code harder to read than >it should be (I mean "back and forth" part of my previous mail). > > matz. > I perfectly understand your argument. Anyone writing code like this x = ( line1; line2; line3; line4; line5; line6; line7; line8; line9; line10; line11; line12; line13; line14; line15; line16; line17; line18; line19; line20; line21; line22; line23; line24; line25; line26; line27; line28; line29; line30) if expr should be shot ;-) although it's legal syntax. Fact is, noone writes it that way. -- stefan