Proposal: New "ends" keyword

No, but someone will, then in order to understand their code you’d have to learn it.

Given the amount of confusion around when/how it would know to stop I’m not so sure more concise|shorter code is the right word. Shorter maybe by a few lines, but deff not more concise.

Granted I’m not familiar with the parser, but I can’t imagine this being easier than the current implementation.

At the moment it knows that class or def will have a related end keyword. As a result it knows to look for this value after the body, and raise an error if it’s not there.

With this change, that would no longer be true as the parser would have to keep track of what was opened, what has been closed via a specific end keyword, and what thing(s) are closed by an ends when it finds one. In additional there would also prob have to be some pretty complex logic to prevent

class Foo
  def bar
    while true
  ends

  if foo
    while true
  ends
end

from not being parsed as:

class Foo
  def bar
    while true
    end
  end
end

  if foo
    while true
    end
  end
end # Error extra end

I’m sure it could be done but the question is should it. At this point, I’m pretty sure you’re the only one who thinks it would be :stuck_out_tongue:.

Could always open a PR to implement it then we can go from there :wink:.

2 Likes