Comment #141
Multiline-Comments should be able to be started at arbitrary indentation levels
| Status: | Open | Start: | 01/05/2010 | |
| Priority: | Normal | Due date: | ||
| Assigned to: | - | % Done: | 0% |
|
| Category: | - | |||
| Target version: | - | |||
| Clause: | 8.4 |
Page and Line: | 10.30 |
|
Description
Currently, source code like this is not possible:
class Something
class Foo
def some_method
end
=begin
This method is a dummy method.
Parameters:
baz: This is a dummy parameter.
=end
def bar(baz)
end
def some_other_method
end
end
end
instead of writing this, programmars are required to write this:
class Something
class Foo
def some_method
end
=begin
This method is a dummy method.
Parameters:
baz: This is a dummy parameter.
=end
def bar(baz)
end
def some_other_method
end
end
end
Note that the "=begin" and "=end" tokens have to be at the beginning of the line. This distorts both the view and the process of writing and modifying the source code. Especially in cases where a whole block of text is indented by some space or tab offset, the resulting source code yields a syntax error.
This behaviour defeats many purposes of having multi-line-comments in the first place, and this behaviour is in conflict with the Principle Of Least Surprise.
This is why, in a standardized Ruby language, the restriction of having the "=begin" and "=end" tokens as the very first tokens of a line (without whitespace) should be relaxed, at least to allow whitespace between beginning of the line and the token. (Maybe more relaxation to allow "=begin" and "=end" at arbitrary locations within the source code should also be considered.)
Related issues
| related to Comment #60 | Processor Conformance's reject clause is too strict | Closed | 12/01/2009 |
History
Updated by Shugo Maeda 245 days ago
Xuân Baldauf wrote:
Note that the "=begin" and "=end" tokens have to be at the beginning of the line. This distorts both the view and the process of writing and modifying the source code. Especially in cases where a whole block of text is indented by some space or tab offset, the resulting source code yields a syntax error.
It is because our primary reference is Ruby 1.8.7, which does not permit whitespaces before "=begin" and "=end".
However, a conforming processor may permit whitespaces before "=begin" and "=end" because it does not break any conforming programs, and syntax extensions are now explicitly permitted in the clause "Conformance" as follows:
A conforming Ruby processor may:
- use an internal model for the Ruby language other than the one described in this document, if it does not change the behavior of a conforming program;
- support syntax not described in this document, and accept any programs which use features not specified in this document;
Please see comment #60 for details.