Quality of error messages

The problem, as with all such systems, is that you are now looking
at something the compiler does not. That's the main reason why salient
structure systems such as python's measurably reduce programmer errors:
if you use them you are perforce seeing what the compiler sees, no more,
no less.

     Remember the old adage: "Don't get suckered in by comments; read
the code"

    -- Markus

P.S. Again, for the record, I am NOT advocating salience for ruby.

···

On Fri, 2004-10-08 at 12:13, Charles Hixson wrote:

markus@reality.com wrote:

> *laugh* I supose the reason I like the abomination is I learned to
>indent back in the days of salient structure (before the matching-pairs
>abomination took over the world). To me (and by extension, all right
>thinking people), python's indentation seems perfectly natural. I suppose
>it's all a matter of what abomination you grew up with.

> That said, it really doesn't hurt as bad as you'd think it would,
>since the main thing people differ on is where to put the closing token
>(e.g., does the "end" or "}" go at the indentation of the enclosed block
>or the inclosing block) and that issue vanishes if you don't have closing
>tokens. I suspect that (if warned) most rubiests would find:
>
> class My_class
> attr_reader :an_atribute
> def initialize a1,a2
> @an_attribute = a1
> @counter = 0
> @limit = a2
> def feed_the_lion food
> raise "Roar" unless food.respond_to? :digestible_by
> raise "Grrr" unless food.digestible_by self
> digest food
>
> waffle = My_class.new :fred,14
>
>perfectly readable (and writable) without all the syntactic clutter/noise.
>Required when you _don't_ pay attention to white space. Further, it's
>well established that when there is discord between them people
>(including long time lispers) will "read the indentation" and ignore the
>punctuation regardless, so it reduces a significant source of bugs to
>have the language look at the same features of the source code as the
>person did. About the only measured downside (IIRC) is that it increases
>the error rate when people are typing in code from a printed source. That
>doesn't happen nearly as much as it used to.
>
> BTW, I am _not_ trying to push this change; I'm just trying to
>explain why I would not object to it, and suspect that many others would
>find it more palatable than they might think.

For that sample, you are correct, but when blocks get a bit more complex
it fails. Miserably in my opinion. Even when programming in Python I
typically add an end statement, e.g.

class My_class:
       def __init__(self, a1,a2):
            self.an_attribute = a1
            self.counter = 0
            self.limit = a2
       #end __init__

       def feed_the_lion(self, food):
            raise "Roar" unless food.respond_to? :digestible_by
            raise "Grrr" unless food.digestible_by self
            digest food
       #end feed_the_lion
#end class My_class
waffle = My_class.new :fred,14

Note this is an incomplete conversion. Also note that I don't just use
end statements, I label them. (Also note that I couldn't decide whether
or not waffle was a member of My_class just by looking at it. It
required noticing that it was an instantiation of the class. (Which I
couldn't remember how to do in Python.)

I guess that I got my block conventions from Ada. (Fortran was
rather....vague about them, except for not before column 6 and not after
column 72.)

My personal convention about when to use {} and when to use do..end is:
If it's within a single line, use {}. Otherwise tend to prefer do..end
This isn't a strong convention, but I try to not depend on relative
binding power (partially because I can never remember the exact
precedence order).

Austin Ziegler wrote:

···

On Fri, 8 Oct 2004 08:36:27 +0900, markus@reality.com > <markus@reality.com> wrote:

    That said, it really doesn't hurt as bad as you'd think it would,
since the main thing people differ on is where to put the closing token
(e.g., does the "end" or "}" go at the indentation of the enclosed block
or the inclosing block) and that issue vanishes if you don't have closing
tokens. I suspect that (if warned) most rubiests would find:

  class My_class
      attr_reader :an_atribute
      def initialize a1,a2
           @an_attribute = a1
           @counter = 0
           @limit = a2
      def feed_the_lion food
           raise "Roar" unless food.respond_to? :digestible_by
           raise "Grrr" unless food.digestible_by self
           digest food

   waffle = My_class.new :fred,14

perfectly readable (and writable) without all the syntactic clutter/noise.

I don't find it readable at all.

I completely, 100%, in every way, concur with Austin. I detest any attempt to enforce an arbitrary indentation style upon me. It's why I chucked Python just months after first learning about it. But that's just my opinion.

- Jamis

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis

Yukihiro Matsumoto wrote:

Hi,

>> % ./script.rb
>> script.rb:6: warning: inconsistent indentation level.
>> script.rb:13: parse error
>>
>> This should make it easy to find such errors.

>That seems like a nice idea to me. This would be nearly the same as the
>autoindenter so, only that it does not indent but spit out warnings.

I'm afraid that it might cause tab-space indentation war like in the
Python community. The issue is much smaller though, since it is not
mandatory.

              matz.

Therefore I like the idea of using a high warning level or a seperate
program for this task. By now I normally
  - mark everything
  - M-x indent-region
  - Look where something is weird.

The unfortunate thing about this is that editor-based indenters never
seem to work perfectly. e.g. what to do with here-docs? Ruby is a
difficult language to indent. Consequently I tend to use the feature
locally, not on the whole file.

If a program could guide where I look that would be nice. Therefore also
an external program or an xemacs plugin would be nice to me.

An external program would be terrific, just becuase it could be used
independently, and also in any editor.

Gavin

···

On Friday, October 8, 2004, 10:14:56 AM, Brian wrote:

In message "Re: quality of error messages" >> on Fri, 8 Oct 2004 05:28:55 +0900, Brian Schröder >> <ruby@brian-schroeder.de> writes:

I think that you don't have to enforce any particular indentation style or
amount of space on each line - only that it is consistent between begin and
end.

If we define the 'nesting depth' as the number of module / class / def / do
/ if sections we are within (i.e. the number of matching 'end's we expect to
see), then:

- at the start of each line, count the number of spaces. Ignore lines which
consist entirely of whitespace.

R1: if the nesting depth is the same as the previous line, then raise a
warning if the number of spaces is not the same as the previous line

R2: if the nesting depth is greater than the previous line, then remember
the indentation of this line associated with this nesting depth (e.g. on a
stack)

R3: if the nesting depth is less than the previous line, then raise a
warning if the number of spaces is not the same as the last line with the
same nesting depth

     *ROFL* Yes! What you have described here is salient structure
(well, missing, IIRC, the line continuation rule and the tab-size
rule). It's a wonderful system, and everybody thinks they use it. But
back in the early nineteen eighties or so someone who didn't understand
the system decided it would be easier to "find pairs" if the closing
token were indented as if it were a member of the enclosing block.
Thus, the algorithm as you stated it would complain

# hello R1: check indentation == 0
class Foo R1: check indentation == 0
  def m [2] R2: push 2
      wibble [2,6] R2: push 2
      bibble [2,6] R1: check indentation == 6
  end [2] R3: check indentation == 2

    ^

at the point marked "^" because (at the start of that line) the nesting
is the same as at was for the previous two lines. The same problem
occurs throughout the example. There are, as always, at least two ways
to fix this.

     One would be to implement the rules as you stated them, adding the
half-step rule (indentations intermediate between the two are used for
syntactic continuation, e.g. else or your chained addition example). I
would love this, since that's the style I use (I was already out of
school before the sea change) but I suspect most if not all of you would
hate it.

     Another way would be to do what python did and avoid the problem by
eliminating closing tokens. I suspect more people would like this, but
matz and the majority (so two majorities? yikes!?) would be against
them.

     A third solution would be to do what I suggested a few hours ago,
the essence of which was to look not for the closing but the occurrence
of something "outer" (< indented, not <= indented), and only telling
about the most recent one when the problem is detected:

        There may be heuristics to get a reasonable "hint" by making
        some assumptions; e.g., warn if there is a line less indented
        than the first line of an outstanding (open) construct,
        excluding here-docs, %_{ constructs, etc., if (and only if)
        there is a missing end at eof [or when the error is detected].
        This could (I think) be implemented fairly easily by

              * caching the location and indentation of a each class,
                def, etc. on a stack

              * popping from the stack on end

              * noting when the first token is lexed from a line if it
                was less indented than the most recent outstanding
                def/class, etc., and if so noting the fact in a global

              * including the information in the global (if any) when
                generating the missing end message

        But this is only a heuristic, based on the observation that even
        people who don't like salient structure tend to use it to some
        extent. It would not solve the problem in general, and perhaps
        not even in a typical case, for anyone but me and the python
        expatriates.

    This is still the best of the options I've heard or thought of.
Instead of using a stack (as we both suggested) it might be easier to
use the parser's tree, which (IIRC) has adequate support for all sorts
of tagging.

One other thing, you'd need to ignore subsequent lines of multi-line
statements:
   a,b,c =
       1,2,3
   foo (
      ...
   )

but I guess the parser must already have a mechanism which infers "the next
line is a continuation of the previous" anyway.

     Yes, it does. I'm not sure I grok its fullness, but it is there
and would be accessible. It wouldn't be needed in the soft-checking
third option (or at least, I don't think it would be needed), but it
wouldn't be too hard to watch for if it was.

      -- Markus

···

On Fri, 2004-10-08 at 04:26, Brian Candler wrote:

But is that an argument against labeling end markers, or an argument in favor of allowing Ruby to optionally recognize them? I agree that it's a true argument, I just consider it better than nothing.

Markus wrote:

    The problem, as with all such systems, is that you are now looking
at something the compiler does not. That's the main reason why salient
structure systems such as python's measurably reduce programmer errors:
if you use them you are perforce seeing what the compiler sees, no more,
no less.

    Remember the old adage: "Don't get suckered in by comments; read
the code"

   -- Markus

P.S. Again, for the record, I am NOT advocating salience for ruby.

...

···

On Fri, 2004-10-08 at 12:13, Charles Hixson wrote:

Here is a simple emacs function that does the job:

(defun ruby-check-ends ()
  (interactive)
  (let (loose-end)
    (save-excursion
      (goto-char (point-min))
      (while (and (not loose-end)
      (re-search-forward "^[ \t]*\\(end\\)[ \t\n]" nil t))
  (goto-char (match-beginning 1))
  (if (not (eq (current-column) (ruby-calculate-indent)))
      (setq loose-end (point)))
  (forward-char)))
    (cond (loose-end
     (goto-char loose-end)
     (message "indentation of end is not correct")))))

It may not work correctly if you use a different style then the
one emacs is set up to, but you will probably use this for your code
anyway.

Regards,
Kristof

···

On Fri, 08 Oct 2004 09:14:56 +0900, Brian Schröder wrote:

If a program could guide where I look that would be nice. Therefore also
an external program or an xemacs plugin would be nice to me.

And just to clarify: This is in no way urgent or very important to me, I
just liked the idea :wink:

>> That said, it really doesn't hurt as bad as you'd think it would,
>>since the main thing people differ on is where to put the closing token
>>(e.g., does the "end" or "}" go at the indentation of the enclosed block
>>or the inclosing block) and that issue vanishes if you don't have closing
>>tokens.

> I don't find it readable at all.

I completely, 100%, in every way, concur with Austin. I detest any
attempt to enforce an arbitrary indentation style upon me.

     No one is trying to enforce anything on anyone here. No one is
even trying to make you eat green eggs and ham.

     I had just been trying to explain (in response, as I recall, to a
question of some sort) how people who use python (and other
salient-structure languages) see the world; they aren't brain damaged
mutants (at least in my opinion), nor are they enslaved masses being
"forced" to use python.

     Some people actually like it, and their reasons are fairly
explicable, just as the reasons for liking (say) perl or smalltalk or
lisp or ruby or forth or...well, you get the point. There's no harm
that I can see in trying to understand someone else's perspective, even
if you don't share it.

    -- Markus

No, no, no, and NO!

When I am writing code, I will often do:

  class Foo
    def bar
      : # some code here
  p baz # a tracer to help me find a difficult bug
      : # more code here
    end
  end

Your suggestion would force me to indent the tracer -- which I have
*purposefully* overridden the auto-formatting by vim to insert --
which leads me to the same idiocy that keeps me from Python as a first
point.

Tracer code is too useful to be bound by people who don't use editors
that help them write their code through use of automatic indentation
and/or folding.

This whole indentation-count idea is dumb.

-austin

···

On Fri, 8 Oct 2004 20:26:55 +0900, Brian Candler <b.candler@pobox.com> wrote:

On Fri, Oct 08, 2004 at 08:06:27AM +0900, Yukihiro Matsumoto wrote:
> >> % ./script.rb
> >> script.rb:6: warning: inconsistent indentation level.
> >> script.rb:13: parse error
> >>
> >> This should make it easy to find such errors.
>
> >That seems like a nice idea to me. This would be nearly the same as the
> >autoindenter so, only that it does not indent but spit out warnings.
>
> I'm afraid that it might cause tab-space indentation war like in the
> Python community. The issue is much smaller though, since it is not
> mandatory.

I think that you don't have to enforce any particular indentation style or
amount of space on each line - only that it is consistent between begin and
end.

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca
: as of this email, I have [ 6 ] Gmail invitations

Gavin Sinclair wrote:

Yukihiro Matsumoto wrote:

Hi,

% ./script.rb
script.rb:6: warning: inconsistent indentation level. script.rb:13: parse error

This should make it easy to find such errors.

That seems like a nice idea to me. This would be nearly the same as the
autoindenter so, only that it does not indent but spit out warnings.

I'm afraid that it might cause tab-space indentation war like in the
Python community. The issue is much smaller though, since it is not
mandatory.

            matz.

Therefore I like the idea of using a high warning level or a seperate
program for this task. By now I normally
- mark everything
- M-x indent-region
- Look where something is weird.

The unfortunate thing about this is that editor-based indenters never
seem to work perfectly. e.g. what to do with here-docs? Ruby is a
difficult language to indent. Consequently I tend to use the feature
locally, not on the whole file.

I've got to say I'm quite impressed with xemacs indentation. (Thanks matz). The only things (but those are really hard to do) are:

indentations when escaping from a string:
<<EOT
blah #{indent do
          this
        end}
EOT

Indentation of lines ending with an operator
line1 +
   line 2 +
   line 3

does not work, so I always use
line 1 + \
line 2 + \
line 3

If a program could guide where I look that would be nice. Therefore also
an external program or an xemacs plugin would be nice to me.

An external program would be terrific, just becuase it could be used
independently, and also in any editor.

And in any case in an external ruby script perfect indentation would be easyer to implement than in elisp.

regards,

Brian

···

On Friday, October 8, 2004, 10:14:56 AM, Brian wrote:

In message "Re: quality of error messages" >>> on Fri, 8 Oct 2004 05:28:55 +0900, Brian Schröder >>><ruby@brian-schroeder.de> writes:

--
Brian Schröder
http://ruby.brian-schroeder.de/

The compiler should complain about incorrectly labeled "end" markers,
but not about missing markers.

If code contains markers the compiler will use them to produce more
precise error messages. If there are no such markers, the compiler
will behave as of now.

Which means that optional "end" markers could be introduced into Ruby's
syntax without any need for a new compiler flag: the syntax change will
have no effect except for code that effectively uses the markers.

- Joachim

···

Charles wrote

But is that an argument against labeling end markers, or an argument in
favor of allowing Ruby to optionally recognize them? [...]

Markus wrote:

> The problem, as with all such systems, is that you are now looking
>at something the compiler does not. That's the main reason why salient
>structure systems such as python's measurably reduce programmer errors:
>if you use them you are perforce seeing what the compiler sees, no more,
>no less. [...]

Markus wrote:

    The problem, as with all such systems, is that you are now looking
>at something the compiler does not. That's the main reason why salient
>structure systems such as python's measurably reduce programmer errors:
>if you use them you are perforce seeing what the compiler sees, no more,
>no less.
>
> Remember the old adage: "Don't get suckered in by comments; read
>the code"

>P.S. Again, for the record, I am NOT advocating salience for ruby.

But is that an argument against labeling end markers, or an argument
in favor of allowing Ruby to optionally recognize them? I agree that
it's a true argument, I just consider it better than nothing.

     So (summarizing my previous posts on this thread):

      * It isn't possible to give useful hints about the location of an
        unclosed structure with out using "out of band" information that
        the compiler presently does not use. Ruby is not being
        intentionally obtuse in its error reporting; it simply does not
        know, and can not know, what construct was left open in
        general. It can't even guess.
      * Therefore if we want better information about the source of
        "missing end" errors, we will have to let the compiler use
        information it does not presently have
      * This is (IMHO) not worth breaking any existing code at all.
      * A guess could be made by looking at the indentation (see
        http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/115641 for the details) provided
              * that we took into account of the fact that most people
                claim to use the salience rules but actually do
                pair-matching
              * No warnings should be generated (the information should
                only be reported in case of an actual error)
      * Augmenting 'end' (optionally) with a structure keyword and a
        name might be possible. It would certainly provide enough
        information, but may or may not be implementable
      * Having the compiler "read comments" is a Bad Idea.
      * I would support any of the ideas that 1) would work and 2) are
        not Bad Ideas.
      * I will argue for the truth, even if in doing so I undermine my
        own prejudices. No strike that. _Especially_ if it will
        undermine my prejudices.

     Does that answer your question?

-- Markus

···

On Fri, 2004-10-08 at 13:45, Charles Hixson wrote:

Kristof Bastiaensen wrote:

···

On Fri, 08 Oct 2004 09:14:56 +0900, Brian Schröder wrote:

If a program could guide where I look that would be nice. Therefore also
an external program or an xemacs plugin would be nice to me.

And just to clarify: This is in no way urgent or very important to me, I
just liked the idea :wink:

Here is a simple emacs function that does the job:

(defun ruby-check-ends ()
  (interactive)
  (let (loose-end)
    (save-excursion
      (goto-char (point-min))
      (while (and (not loose-end)
      (re-search-forward "^[ \t]*\\(end\\)[ \t\n]" nil t))
  (goto-char (match-beginning 1))
  (if (not (eq (current-column) (ruby-calculate-indent)))
      (setq loose-end (point)))
  (forward-char)))
    (cond (loose-end
     (goto-char loose-end)
     (message "indentation of end is not correct")))))

It may not work correctly if you use a different style then the
one emacs is set up to, but you will probably use this for your code
anyway.

Regards,
Kristof

Nicely done! I added it to my init.el. And again I learned a bit more elisp.

regards,

Brian
--
Brian Schröder
http://ruby.brian-schroeder.de/

Markus wrote:

   That said, it really doesn't hurt as bad as you'd think it would,
since the main thing people differ on is where to put the closing token
(e.g., does the "end" or "}" go at the indentation of the enclosed block
or the inclosing block) and that issue vanishes if you don't have closing
tokens.

I don't find it readable at all.

I completely, 100%, in every way, concur with Austin. I detest any attempt to enforce an arbitrary indentation style upon me.

     Some people actually like it, and their reasons are fairly
explicable, just as the reasons for liking (say) perl or smalltalk or
lisp or ruby or forth or...well, you get the point. There's no harm
that I can see in trying to understand someone else's perspective, even
if you don't share it.

I understand that people like that approach. I don't begrudge them that. But they use Python because they like that approach, and I don't use Python because I don't like that approach. Like Austin, I do not find that it adds readability to the code--I actually feel that it detracts from the readability.

But that's my opinion. I'm not out to change Python, and I don't think Python users are, as you said, "brain damaged mutants." I also do not think anyone is forcing them to use Python. They use Python because it fits their preferred coding style.

It does not fit mine.

I simply get touchy when people start suggesting that perhaps Ruby ought to adopt such a style. My apologies if I ruffled any feathers.

- Jamis

···

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis

Austin Ziegler wrote:

% ./script.rb
script.rb:6: warning: inconsistent indentation level.
script.rb:13: parse error

This should make it easy to find such errors.

That seems like a nice idea to me. This would be nearly the same as the
autoindenter so, only that it does not indent but spit out warnings.

I'm afraid that it might cause tab-space indentation war like in the
Python community. The issue is much smaller though, since it is not
mandatory.

I think that you don't have to enforce any particular indentation style or
amount of space on each line - only that it is consistent between begin and
end.

No, no, no, and NO!

When I am writing code, I will often do:

  class Foo
    def bar
      : # some code here
  p baz # a tracer to help me find a difficult bug
      : # more code here
    end
  end

Your suggestion would force me to indent the tracer -- which I have
*purposefully* overridden the auto-formatting by vim to insert --
which leads me to the same idiocy that keeps me from Python as a first
point.

Tracer code is too useful to be bound by people who don't use editors
that help them write their code through use of automatic indentation
and/or folding.

This whole indentation-count idea is dumb.

-austin

What are you fearing? No one proposed that the above code should:
1) not work anymore
2) produce warning messages

what was proposed is:
if there is a missing end, produce the message:
"missing a closing end. Your indentation suggests that the missing end could belong to 'def bar' on line 234."

So I see nobody forcing anything upon you.

No reason to CRY OUT LOUD.

Brian Schröder

···

On Fri, 8 Oct 2004 20:26:55 +0900, Brian Candler <b.candler@pobox.com> wrote:

On Fri, Oct 08, 2004 at 08:06:27AM +0900, Yukihiro Matsumoto wrote:

--
Brian Schröder
http://ruby.brian-schroeder.de/

> > >> % ./script.rb
> > >> script.rb:6: warning: inconsistent indentation level.
> > >> script.rb:13: parse error
> > >>
> > >> This should make it easy to find such errors.
> >
> > >That seems like a nice idea to me. This would be nearly the same as the
> > >autoindenter so, only that it does not indent but spit out warnings.
> >
> > I'm afraid that it might cause tab-space indentation war like in the
> > Python community. The issue is much smaller though, since it is not
> > mandatory.
>
> I think that you don't have to enforce any particular indentation style or
> amount of space on each line - only that it is consistent between begin and
> end.

No, no, no, and NO!

     Austin. Pause. Take a deep breath. Let it out slowly. You are
misunderstanding what has been discussed, and what has been
implemented. There is no need for panic.

     What people are suggesting is a way to help them find missing
'end's in their code. At present, the error message is not particularly
helpful. It gives no indication of where the problem might be. So what
we have done is prototyped a way to guess where the error might be,
based on common patterns of indentation. That is all.

      * It does not enforce, coerce, mandate, or even recommend any
        particular indentation style.
      * It does not alter the interpretation of any ruby program.
      * It does not generate any messages unless the program fails to
        parse, and only then in the case where a missing 'end' or '}' is
        likely. In that case, all it does is add a list of line numbers
        to the message (as warnings) indicating a small number of places
        where the error might be.

When I am writing code, I will often do:

  class Foo
    def bar
      : # some code here
  p baz # a tracer to help me find a difficult bug
      : # more code here
    end
  end

     And you may freely continue to do so. No one is saying otherwise.

Your suggestion would force me to indent the tracer -- which I have
*purposefully* overridden the auto-formatting by vim to insert --
which leads me to the same idiocy that keeps me from Python as a first
point.

      There are several interesting points to discuss here, but I fear
to raise them lest I upset you further. Perhaps later, once your main
concerns have been addressed.

Tracer code is too useful to be bound by people who don't use editors
that help them write their code through use of automatic indentation
and/or folding.

     If you are using automation tools to help you write code presumably
you have other, better ways of localizing missing 'end's. So you would
never even see the warnings. If you (or others who code like you) would
like the messages to be helpful to them as well, I suspect there may be
a simple heuristic or two that would handle it. The indentation-reader
uses a _very_ loose definition of salience already, to accommodate the
wide range of styles found in the code I looked at.

This whole indentation-count idea is dumb.

      I agree that the idea you are reacting to may be is dumb, or at
least ill advised in this context. But that is not the idea under
discussion. If possible, I would be interested in hearing your thoughts
on the actual idea, which is laid out here:

http://blade.nagaokaut.ac.jp/ruby/ruby-core/3486

(including a link to my first attempt at implementing such as system).

-- Markus

···

On Mon, 2004-10-11 at 14:46, Austin Ziegler wrote:

On Fri, 8 Oct 2004 20:26:55 +0900, Brian Candler <b.candler@pobox.com> wrote:
> On Fri, Oct 08, 2004 at 08:06:27AM +0900, Yukihiro Matsumoto wrote:

Austin Ziegler wrote:

I think that you don't have to enforce any particular indentation style or
amount of space on each line - only that it is consistent between begin and
end.

No, no, no, and NO!

:slight_smile: Are you still ticked off after your system crash?

[snip re tracers etc.]

This whole indentation-count idea is dumb.

I sympathize with both sides. Like you, I "flush left" my debug lines
(fighting vim to do so, and hating the idea of coding without being
able to do such).

I typically don't leave those in long, however. YMMV.

But the whole discussion here has nothing to do with enforcing a
coding style -- it's just a heuristic that would be invoked ONLY in
the case of a missing closing delimiter, and I hope ONLY when a
high level of warnings were turned on.

And by the way, an extra line of code or two could probably allow the
insertion of rogue left-justified lines. But that's beside the point.

The only goal discussed here afaik is: How could we get an error message
like:

    Probable missing 'end' line 123

instead of:

    Syntax error line 896

at end of file, hundreds of lines away from the error.

Hal

> > >> % ./script.rb
> > >> script.rb:6: warning: inconsistent indentation level.
> > >> script.rb:13: parse error
> > >>
> > >> This should make it easy to find such errors.
> >
> > >That seems like a nice idea to me. This would be nearly the same as the
> > >autoindenter so, only that it does not indent but spit out warnings.
> >
> > I'm afraid that it might cause tab-space indentation war like in the
> > Python community. The issue is much smaller though, since it is not
> > mandatory.
>
> I think that you don't have to enforce any particular indentation style or
> amount of space on each line - only that it is consistent between begin and
> end.

No, no, no, and NO!

Yikes!

When I am writing code, I will often do:

  class Foo
    def bar
      : # some code here
  p baz # a tracer to help me find a difficult bug
      : # more code here
    end
  end

Your suggestion would force me to indent the tracer -- which I have
*purposefully* overridden the auto-formatting by vim to insert --
which leads me to the same idiocy that keeps me from Python as a first
point.

Well, no, it wouldn't. In my original suggestion:
1. it was only a warning; you wouldn't be *forced* to comply with it.
2. the warning would be at a more highly defined warning level: level
3, which currently doesn't exist. So the warning would never show up
unless you run your code at that warning level.
3. I didn't directly specify this, but I intended that it would only
check indentation levels for block ends. So that puts statement would
be ignored even still.

I would shrink in horror at the thought of supporting a change that
would enforce indentation standards on other rubyists. I violate mine
often enough myself, whenever I feel that it makes my code more
readable.

Regardless, I realize now that the exact thing I proposed would not be
the best way of doing it. I described what was in my mind at the time,
knowing full well that there was likely something wrong with the idea.
:slight_smile: I am quite interested in the much more mature ideas that I've seen
later on in this thread.

Tracer code is too useful to be bound by people who don't use editors
that help them write their code through use of automatic indentation
and/or folding.

This whole indentation-count idea is dumb.

Well, I guess that we will all have different opinions on this, but I
find myself tracking down "missing end" bugs often enough that I kinda
like the idea. As long as it only complains when there's a missing end
:slight_smile:

cheers,
Mark

···

On Tue, 12 Oct 2004 06:46:55 +0900, Austin Ziegler <halostatue@gmail.com> wrote:

On Fri, 8 Oct 2004 20:26:55 +0900, Brian Candler <b.candler@pobox.com> wrote:
> On Fri, Oct 08, 2004 at 08:06:27AM +0900, Yukihiro Matsumoto wrote:

I simply get touchy when people start suggesting that perhaps Ruby ought
to adopt such a style.

     No one that (I heard) suggested such a thing. We were talking
about how one might use the information implicit in people's normal
indentation style (whatever they choose) to guess the location of a
missing 'end'--which the present compiler typically reports as a 'parse
error' at the end of the file.

     For what it's worth, I have an experimental patch (yes, in fact I
am a glutton for punishment) that does very well at finding ends I've
deleted from arbitrary ruby code. It doesn't rely on any particular
indentation style (it would "work" even if you indented at random, but
it's hints would likely be no more helpful than the present message) and
doesn't do anything if there are no missing ends.

     If you are interested, it can be found via

http://blade.nagaokaut.ac.jp/ruby/ruby-core/3486

Note that it doesn't impose anything on anybody. All it does is add a
few possibly helpful line numbers to an otherwise terse error message.

My apologies if I ruffled any feathers.

     No worries. I'm just trying to dampen the extreme polarization
that seems to happen when people react to an excerpt from a more
involved discussion.

-- Markus

Austin Ziegler wrote:
>>I think that you don't have to enforce any particular indentation style or
>>amount of space on each line - only that it is consistent between begin and
>>end.
> No, no, no, and NO!
:slight_smile: Are you still ticked off after your system crash?

I'm annoyed that I haven't been able to do any Ruby coding for the
last week :slight_smile: But I'm also finding these "let's change Ruby into
something else" discussions rather annoying with some of the proposed
directions.

1) Ranges: I have used the fact of 1...2 including 1.99 but not 2.0 in
the past. I don't think that this is something I want to change. I
would like to be able to have mutable ranges (including the ability to
make a range exclusive or inclusive after creation), but I think that
the syntax for ranges is right and consistent for 98% of all users of
Ruby.
2) Operators: I want += to be still automatically defined when I
define +. I agree with Matz about user precedence, although I think
that having a couple of fixed precedence values (instead of one) is
acceptable, to allow for things like := having a reasonably high
precedence.
3) This. I don't think that what has been suggested will be all that
useful. I have encountered a few of these missing "end" issues, and
with the folding that is in the vim-ruby package offered by the
community, I have rarely found that it takes me longer than five
minutes to fix this issue.

I sympathize with both sides. Like you, I "flush left" my debug lines
(fighting vim to do so, and hating the idea of coding without being
able to do such).

I typically don't leave those in long, however. YMMV.

Me, either.

I think that there are possibilities here, though, now that it's been
explained that this is something to show up only in an error
condition.

-austin

···

On Tue, 12 Oct 2004 09:21:16 +0900, Hal Fulton <hal9000@hypermetrics.com> wrote:
--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca
: as of this email, I have [ 6 ] Gmail invitations

Hi --

> Austin Ziegler wrote:
> >>I think that you don't have to enforce any particular indentation style or
> >>amount of space on each line - only that it is consistent between begin and
> >>end.
> > No, no, no, and NO!
> :slight_smile: Are you still ticked off after your system crash?

I'm annoyed that I haven't been able to do any Ruby coding for the
last week :slight_smile: But I'm also finding these "let's change Ruby into
something else" discussions rather annoying with some of the proposed
directions.

1) Ranges: I have used the fact of 1...2 including 1.99 but not 2.0 in
the past. I don't think that this is something I want to change. I
would like to be able to have mutable ranges (including the ability to
make a range exclusive or inclusive after creation), but I think that
the syntax for ranges is right and consistent for 98% of all users of
Ruby.

With all the recent talk about ranges (much, but not all, of which
I've read), I've been trying to put my finger on why I find the idea
of a mutable Range sort of paradoxical. I'm far from having any kind
of sound theoretical grounding or rationale... but anyway:

I think of a range as kind of a fact. For example: (0..10) is "the
fact of being between 0 and 10, inclusive". In which case, changing
*that fact* -- e.g., having "the fact of being between 0 and 10"
*itself* become "the fact of being between 6 and 12" -- makes no
sense. I guess I think of ranges almost more like numbers; it would
make sense to me if (0..10) were literally the same object everywhere
it appeared.

Anyway, all very speculative, but kind of interesting (to me at least
:slight_smile:

David

···

On Tue, 12 Oct 2004, Austin Ziegler wrote:

On Tue, 12 Oct 2004 09:21:16 +0900, Hal Fulton <hal9000@hypermetrics.com> wrote:

--
David A. Black
dblack@wobblini.net