[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: quality of error messages

Markus

10/6/2004 10:39:00 PM

On Wed, 2004-10-06 at 15:19, Joachim Wuttke wrote:
> Thank you, Brian.
> This is quite a convincing example: I count not less than eight
> places where the "end" could be missing.
> Just for curiosity: why didn't Ruby borrow indentation semantics
> from Python ?

Now there's an RCR I'd support. Heck, I'd even volunteer to code
it!

-- Markus

P.S. I've already got a salient structure lex/yacc setup around here
somewhere...



72 Answers

Mark Hubbart

10/7/2004 6:51:00 PM

0

On Thu, 7 Oct 2004 07:39:04 +0900, Markus <markus@reality.com> wrote:
> On Wed, 2004-10-06 at 15:19, Joachim Wuttke wrote:
> > Thank you, Brian.
> > This is quite a convincing example: I count not less than eight
> > places where the "end" could be missing.
> > Just for curiosity: why didn't Ruby borrow indentation semantics
> > from Python ?
>
> Now there's an RCR I'd support. Heck, I'd even volunteer to code
> it!

That's been hashed and rehashed here before... :) I'm guessing it's
unlikely. However, just because whitespace (except newlines) is not
syntactically relevant as far as ruby is concerned, doesn't mean it's
not syntactically relevant as far as the programmers are concerned.

What if we had a new warning level that checked for proper indentation
levels? By default, it could check any common indentation methods, so
one could use tabs, two, three four spaces, whatever; a strict mode
might check for standard library compatible code formatting.

So you might get this kind of warning:

------ script.rb ------

#!usr/local/bin/ruby -W3

class Foo
def initialize
puts "Hello World"
end

class Bar
def initialize
puts "Hello Bar"
end
end

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

This should make it easy to find such errors.

cheers,
Mark


Brian Schröder

10/7/2004 8:29:00 PM

0

Mark Hubbart wrote:
> On Thu, 7 Oct 2004 07:39:04 +0900, Markus <markus@reality.com> wrote:
>
>>On Wed, 2004-10-06 at 15:19, Joachim Wuttke wrote:
>>
>>>Thank you, Brian.
>>>This is quite a convincing example: I count not less than eight
>>>places where the "end" could be missing.
>>>Just for curiosity: why didn't Ruby borrow indentation semantics
>>>from Python ?
>>
>> Now there's an RCR I'd support. Heck, I'd even volunteer to code
>>it!
>
>
> That's been hashed and rehashed here before... :) I'm guessing it's
> unlikely. However, just because whitespace (except newlines) is not
> syntactically relevant as far as ruby is concerned, doesn't mean it's
> not syntactically relevant as far as the programmers are concerned.
>
> What if we had a new warning level that checked for proper indentation
> levels? By default, it could check any common indentation methods, so
> one could use tabs, two, three four spaces, whatever; a strict mode
> might check for standard library compatible code formatting.
>
> So you might get this kind of warning:
>
> ------ script.rb ------
>
> #!usr/local/bin/ruby -W3
>
> class Foo
> def initialize
> puts "Hello World"
> end
>
> class Bar
> def initialize
> puts "Hello Bar"
> end
> end
>
> % ./script.rb
> script.rb:6: warning: inconsistent indentation level.
> script.rb:13: parse error
>
> This should make it easy to find such errors.
>
> cheers,
> Mark
>

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.

In the course I'm giving right now I saw that "missing ends" problems
are the most common problem for the beginners.
(Especially since they had a python course last week ;)

Maybe someone who is writing a ruby-parser will write this and the auto
indenter as a test-script for his parser ;)

Regards,

Brian
--
Brian Schröder
http://ruby.brian-sch...


Austin Ziegler

10/7/2004 8:58:00 PM

0

On Thu, 7 Oct 2004 07:39:04 +0900, Markus <markus@reality.com> wrote:
> On Wed, 2004-10-06 at 15:19, Joachim Wuttke wrote:
> > Thank you, Brian.
> > This is quite a convincing example: I count not less than eight
> > places where the "end" could be missing.
> > Just for curiosity: why didn't Ruby borrow indentation semantics
> > from Python ?
> Now there's an RCR I'd support. Heck, I'd even volunteer to code
> it!

I think you'll find more people who don't want such an abomination.

Python's indentation is the number one thing that prevents me from
even considering using that language, because it forces me to work in
a stupid manner (e.g., *its* manner), rather than adapting to my
manner.

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


Charles Mills

10/7/2004 9:44:00 PM

0

On Oct 7, 2004, at 1:57 PM, Austin Ziegler wrote:

> On Thu, 7 Oct 2004 07:39:04 +0900, Markus <markus@reality.com> wrote:
>> On Wed, 2004-10-06 at 15:19, Joachim Wuttke wrote:
>>> Thank you, Brian.
>>> This is quite a convincing example: I count not less than eight
>>> places where the "end" could be missing.
>>> Just for curiosity: why didn't Ruby borrow indentation semantics
>>> from Python ?
>> Now there's an RCR I'd support. Heck, I'd even volunteer to code
>> it!
>
> I think you'll find more people who don't want such an abomination.
>
> Python's indentation is the number one thing that prevents me from
> even considering using that language, because it forces me to work in
> a stupid manner (e.g., *its* manner), rather than adapting to my
> manner.

I feel the same way as Austin here.
Although there have been a few times where I have had to break a script
up into smaller tmp files to figure out where the unclosed
block/if/.../ started. A separate utility to check the indentation
would be useful (IMHO), but I don't think it really belongs in the main
parser (or in Ruby at all).

-Charlie



Mark Hubbart

10/7/2004 10:07:00 PM

0

On Fri, 8 Oct 2004 06:43:35 +0900, Charles Mills <cmills@freeshell.org> wrote:
> On Oct 7, 2004, at 1:57 PM, Austin Ziegler wrote:
>
> > On Thu, 7 Oct 2004 07:39:04 +0900, Markus <markus@reality.com> wrote:
> >> On Wed, 2004-10-06 at 15:19, Joachim Wuttke wrote:
> >>> Thank you, Brian.
> >>> This is quite a convincing example: I count not less than eight
> >>> places where the "end" could be missing.
> >>> Just for curiosity: why didn't Ruby borrow indentation semantics
> >>> from Python ?
> >> Now there's an RCR I'd support. Heck, I'd even volunteer to code
> >> it!
> >
> > I think you'll find more people who don't want such an abomination.
> >
> > Python's indentation is the number one thing that prevents me from
> > even considering using that language, because it forces me to work in
> > a stupid manner (e.g., *its* manner), rather than adapting to my
> > manner.
>
> I feel the same way as Austin here.
> Although there have been a few times where I have had to break a script
> up into smaller tmp files to figure out where the unclosed
> block/if/.../ started. A separate utility to check the indentation
> would be useful (IMHO), but I don't think it really belongs in the main
> parser (or in Ruby at all).

At first I was thinking that it should be a separate program; but then
I was thinking about how unhelpful the error messages that are
generated by the "missing end" error are. Integrating the indentation
check into the parser would allow for the automatic detection of that
type of error. Since it should only check for *consistent* indentation
levels, it should be flexible enough to allow people to use it
constantly.

cheers,
Mark


T. Onoma

10/7/2004 10:34:00 PM

0

On Thursday 07 October 2004 04:57 pm, Austin Ziegler wrote:
| On Thu, 7 Oct 2004 07:39:04 +0900, Markus <markus@reality.com> wrote:
| > On Wed, 2004-10-06 at 15:19, Joachim Wuttke wrote:
| > > Thank you, Brian.
| > > This is quite a convincing example: I count not less than eight
| > > places where the "end" could be missing.
| > > Just for curiosity: why didn't Ruby borrow indentation semantics
| > > from Python ?
| >
| > Now there's an RCR I'd support. Heck, I'd even volunteer to code
| > it!
|
| I think you'll find more people who don't want such an abomination.
|
| Python's indentation is the number one thing that prevents me from
| even considering using that language, because it forces me to work in
| a stupid manner (e.g., *its* manner), rather than adapting to my
| manner.

Probably it would be "bestest" if Ruby had used { ... } and/or do ... end in
all places.

class Foo {

}

def bar(baz) {

}

if x == 32 do

end

etc.

I bet parsing would be tad faster too.

T.


Yukihiro Matsumoto

10/7/2004 11:06:00 PM

0

Hi,

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

|> % ./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.



Markus

10/7/2004 11:36:00 PM

0

Brian Schröder

10/8/2004 12:15:00 AM

0

Yukihiro Matsumoto wrote:
> Hi,
>
> In message "Re: quality of error messages"
> on Fri, 8 Oct 2004 05:28:55 +0900, Brian Schröder <ruby@brian-schroeder.de> writes:
>
> |> % ./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.

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 ;)

Regards,

Brian
--
Brian Schröder
http://ruby.brian-sch...


Gavin Sinclair

10/8/2004 3:30:00 AM

0

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

> Yukihiro Matsumoto wrote:
>> Hi,
>>
>> In message "Re: quality of error messages"
>> on Fri, 8 Oct 2004 05:28:55 +0900, Brian Schröder
>> <ruby@brian-schroeder.de> writes:
>>
>> |> % ./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