On Mon, Jul 12, 2010 at 12:59 PM, Jan Lelis <prog / janlelis.de> wrote:
>> [...] I question the balance of effort and benefit.
>> Since most code around does not use the new syntax, you will have to
>> support the old syntax as well.      
>> people benefit that use it.  Ȭ    >> backporting new code to projects that only use an old Ruby
>> interpreter.
>
> The backporting effort for 99% of the cases: code.gsub /end~(class|
> module|def|begin|if|unless|while|until|for|do|case)/, 'end'
>
>
>> Given that we do not have this feature today and most
>> people seem to be able to write code that gets the nesting right I
>> wonder what the real benefit of this is given that there will be
>> development effort for the interpreter, test cases, documentation etc.
>
> Of course, you are able to write code with the right nesting, else it
> wouldn't run ;). That doesn't mean, that it is easy to write or read.
>
>> Uglyness was really just a side aspect although I agree I should have
>> made this more clear.      >> points are obvious. :-)
>
> Is it really that ugly? I want to emphasize that the additions would be
> optional. I really think of using it only, when there are three ore more
> consecutive ends. But then, it is really helpful (please also see the
> example at bottom).
>
>> [...] Even such a
>> small change can cause significant other work to be done.
>
> That is true :/
>
>> If you want help figuring out how to do this, I'll be glad to give you
>> advice, tho you'll have to write it. Doing something like this the
>> right way is going to be quite difficult unless you know where to
>> start, and even after that will be fairly tricky. Unless you're an
>> expert on parsing ruby, you need the assistance of someone (like me)
>> who is.
>
> Thank you for this nice offer. I would gladly take it :) [but as I said,
> I have much to to do, so it would be possible at the earliest in about a
> month].
>
> But we still have different opinions about whether the syntax would
> involve punctuation. I think with it, the code is better readable in
> cases like this:
>
> def test
>   >  >     
>   >  
>
>  > 2
>  > 9
>  >   >  
> end
>
Hi,
I know it's a bit of a contrived example, and I'm not advocating a version
of "Ruby Golf" here, but if I saw this method in some code I was maintaining
I would refactor it to something like:

def test
  while 1
    puts (1..9).each_slice(3).map do |slice|
      sum = slice.inject { |acc, ele| acc + ele }
      sum > 6 ? 42 : 99
    end.join(',')
  end
end

...or even better, move the "summing" to another method...

def test
  while 1
    puts (1..9).each_slice(3).map do |slice|
      calculate_sum > 6 ? 42 : 99
    end.join(',')
  end
end

def calculate_sum(items)
  items.inject { |acc, ele| acc + ele }
end

I think most cases where the end~if syntax is "necessary" would be better off
(e.g. more readable) with a healthy dose of refactoring.