For me, at least, this tends to make code kind of difficult to read.
This is what I've always seen in Ruby code before recent trends:
def foo(bar)
puts bar
end
Is this some kind of bleed-over from Python's lack of ending delimiters
for indented code? Does it follow from Whitesmiths style indentation?
Is it perhaps a case of people being unaware that good editors can
properly handle auto-indentation for Ruby? Is it actually an emerging
preference in Ruby culture? I'm curious about why I see this more and
more often lately (though still notably less often, especially among
experienced coders, than the style with "end" keywords at the same
indentation level as whatever started the indented block of code -- at
the same indentation level as the "def" keyword, in this case).
I've never seen this even once except when it was a mistake, but maybe
it's just me. Are you seeing this usage in prominent Ruby
frameworks/libraries (e.g. Rails, Sinatra, etc.) or Ruby code?
On Thu, May 12, 2011 at 16:51, Chad Perrin <code@apotheon.net> wrote:
I've been seeing a lot of this lately:
def foo(bar)
puts bar
end
For me, at least, this tends to make code kind of difficult to read.
This is what I've always seen in Ruby code before recent trends:
def foo(bar)
puts bar
end
Is this some kind of bleed-over from Python's lack of ending delimiters
for indented code? Does it follow from Whitesmiths style indentation?
Is it perhaps a case of people being unaware that good editors can
properly handle auto-indentation for Ruby? Is it actually an emerging
preference in Ruby culture? I'm curious about why I see this more and
more often lately (though still notably less often, especially among
experienced coders, than the style with "end" keywords at the same
indentation level as whatever started the indented block of code -- at
the same indentation level as the "def" keyword, in this case).
Ruby 1.9.3dev emits a warning when you pull this kind of stunt:
$ ./ruby19 -v -
ruby 1.9.3dev (2011-05-13 trunk 31536) [x86_64-darwin10.7.0]
def foo(bar)
puts bar
end
-:3: warning: mismatched indentations at 'end' with 'def' at 1
No -- mostly just in code by relatively new Rubyists, such as questions
sent to this very discussion venue. People don't tend to comment on the
formatting, though, so I was wondering if it was becoming accepted
practice. One example is the Email Parsing thread that started just
before this thread, which contains code like this:
It just seemed odd to me that people were answering the querents'
questions and never (apparently) batting an eye at the bizarre
indentation practices.
···
On Fri, May 13, 2011 at 06:11:45AM +0900, John Feminella wrote:
I've never seen this even once except when it was a mistake, but maybe
it's just me. Are you seeing this usage in prominent Ruby
frameworks/libraries (e.g. Rails, Sinatra, etc.) or Ruby code?
Is this is "real" code (e.g., source of gems, etc.) or in snippets? If
its cut and pasted from, e.g., irb with autoindent it will look like
that.
Agreed. Cut n paste is a bitch that will rape your syntax. It has no
mercy. Trust it not. Opining that I'd postulate these probing
stabbings may be unwarranted.
It does look pythony though. Is that were it's coming from?
That is, by the way, not an error I've ever seen -- and not one I expect
to see any time soon, either.
···
On Fri, May 13, 2011 at 08:58:06AM +0900, Eric Hodel wrote:
On May 12, 2011, at 1:51 PM, Chad Perrin wrote:
> I've been seeing a lot of this lately:
>
> def foo(bar)
> puts bar
> end
Ruby 1.9.3dev emits a warning when you pull this kind of stunt:
$ ./ruby19 -v -
ruby 1.9.3dev (2011-05-13 trunk 31536) [x86_64-darwin10.7.0]
def foo(bar)
puts bar
end
-:3: warning: mismatched indentations at 'end' with 'def' at 1
On Fri, May 13, 2011 at 05:59:59AM +0900, serialhex wrote:
On Thu, May 12, 2011 at 4:56 PM, Ryan Davis <ryand-ruby@zenspider.com>wrote:
> On May 12, 2011, at 13:51 , Chad Perrin wrote:
> >
> > I've been seeing a lot of this lately:
> >
> > def foo(bar)
> > puts bar
> > end
>
> Find them.
> Stab them.