I quickly acclimated to Stefan's && idiom and now happily read and write 
code containing it.  That said, it did throw me for a loop when first 
learning the language.  I'm not too big of a fan of reserving another 
keyword for an optional syntax… but I could perhaps support its inclusion 
if it were *only* for one-line if statements and didn't require a 
terminating `end` (and had no support for else/elseif clauses):

if 4 == 2+2 then go_home()


On Friday, March 21, 2014 4:54:53 PM UTC-4, Stefan Karpinski wrote:
>
> On the other hand, saying "4 == 2 + 2 or go home" is perfectly reasonable 
> ;-)
>
>
> On Thu, Mar 20, 2014 at 6:47 PM, John Myles White 
> <johnmyl...@gmail.com<javascript:>
> > wrote:
>
>> To me, this actually explains why the i == 1 && do_stuff() idiom feels so 
>> unnatural: you'd never mix a declarative statement with an imperative 
>> statement in English using only an "and" or an "or". "4 == 2 + 2 and go 
>> home" is verging on being Doge.
>>
>>  -- John
>>
>>
>> On Mar 20, 2014, at 2:46 PM, Stefan Karpinski 
>> <ste...@karpinski.org<javascript:>> 
>> wrote:
>>
>> I always just read them like this:
>>
>> cond "and" do_something
>> cond "or" do_something
>>
>>
>> That seems like it reads pretty naturally to me. This is also one of the 
>> reasons I've occasionally brought up the idea of having "and" and "or" 
>> keywords.
>>
>>
>> On Thu, Mar 20, 2014 at 5:27 PM, Leah Hanson <astri...@gmail.com<javascript:>
>> > wrote:
>>
>>> I'm not so sure about i == 1 && do_stuff() being readable, but I think 
>>> it's better than do_stuff() if i==1. Every time I see i==1 && do_stuff(), I 
>>> have to stop and reason about what it's doing, but at least it isn't 
>>> tricky. With && either you can read it easily, or you see that something 
>>> weird is going on; with end of line if's, it's always this surprising thing 
>>> where you need to reconsider the preceding part of the line (which makes it 
>>> much more appealing for the person *writing* the code than the one 
>>> *reading* it.
>>>
>>> -- Leah
>>>
>>>
>>> On Thu, Mar 20, 2014 at 4:16 PM, Jacob Quinn 
>>> <quinn....@gmail.com<javascript:>
>>> > wrote:
>>>
>>>> I agree. I've never liked python's do_stuff() if i == 1. It's too 
>>>> disconcerting to parse what's going on and then have to backtrack and 
>>>> think 
>>>> about the condition that came afterwards. I've found the i == 1 && 
>>>> do_stuff() has become really natural after only using it a few times.
>>>>
>>>> -Jacob
>>>>
>>>>
>>>> On Thu, Mar 20, 2014 at 5:13 PM, Ivar Nesje <iva...@gmail.com<javascript:>
>>>> > wrote:
>>>>
>>>>> The suffix `if` and `unless` is the reason I never managed to become 
>>>>> literate in Ruby. Maybe it is just a matter of time and experience, but I 
>>>>> read code lines from left to right, and my mental read buffer is not long 
>>>>> enough to see the `if` that someone hid at the end of the line.
>>>>>
>>>>
>>>>
>>>
>>
>>
>

Reply via email to