[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: Aesthetics of while ... do ... end versus while ...: ... end
From: Daniel Brockman <daniel () brockman ! se>
Date: 2005-08-31 16:32:52
Message-ID: 87y86iqddv.fsf () wigwam ! deepwood ! net
[Download RAW message or body]
Nikolai Weibull <mailing-lists.ruby-talk@rawuncut.elitemail.org> writes:
>> I disagree, and I don't see why everyone hates
>> the semicolon.
>>
>> I think it is more consistent to write
>>
>> while foo; bar; baz; quux; end
>>
>> [...]
>
> Yes, but you can write it as
>
> while foo: bar; baz; quux end
>
> Which, in my opinion, clearly separates the foo from the
> bar and the baz.
Since we're already discussing mitutiae, I'll chime in and
say that I too prefer the colon here, simply because it
makes for more readable code. I'd write it as follows:
while foo: bar ; baz ; quux end
I always put spaces around semicolons in Ruby code ---
perhaps to reflect their rather symmetrical nature...
Actually, I'd probably use `do' rather than the colon.
I'd like to see `do' and `:' allowed after `def'.
def delta: last - first end
def request_foo do send "NEED FOO" end
In re while modifiers, I have defined a high-precedence
statement separator operator called `and then', which I
occasionally use when writing two-statement while loops:
lather and then rinse while dirty?
Apart from the higher precedence, the semantics of `foo and
then bar' is the same as `foo ; bar'. The preprocessor
translates `foo and then bar' into `foo or true and bar'.
No punchline, just some random thoughts.
--
Daniel Brockman <daniel@brockman.se>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic