[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

Peña, Botp

10/8/2004 10:57:00 AM

Randy W. Sims [mailto:ml-ruby@thepierianspring.org] wrote:

> Like another poster, I'm in the habit of writing the close marker
> immediately after the open marker. However, one style guide I
> sometimes
> follow is that if a block exceeds one "page" or if I have some deeply
> nested code, I will comment the end(s):
>
> class Foo
> def bar
> puts 'bar'
> end#bar
> end # class Foo

compare:

class Foo
def bar
puts 'bar'
if foo
endif
enddef
endclass

I'm only suggesting this as an option to ruby -c

like

ruby -c -check_extended_end

still we make endclass/enddef/endif synonyms to end, thus programmer is free
to use them or not.

and w regards to indents

ruby -c -check_indent

Again, programmer is free to use indents (as syntax check) or not.

kind regards -botp




6 Answers

Charles Hixson

10/8/2004 7:48:00 PM

0

Peña, Botp wrote:

>Randy W. Sims [mailto:ml-ruby@thepierianspring.org] wrote:
>...
>
>I'm only suggesting this as an option to ruby -c
>like
>ruby -c -check_extended_end
>still we make endclass/enddef/endif synonyms to end, thus programmer is free
>to use them or not.
>and w regards to indents
>ruby -c -check_indent
>Again, programmer is free to use indents (as syntax check) or not.
>kind regards -botp
>
Perhaps they shouldn't be strict equivalents. I'd prefer that endclass
NOT be able to close an if statement. But as long as the generic end
statement was retained, then which variant to use could be a matter of
taste and circumstance. And if we're going to go in that direction, the
perhaps the class/routine name could be an optional parameter. This
could result in something like:

class Foo
def bar
puts 'bar'
if foo
.... stuff....
endif
enddef bar
endclass Foo

Or perhaps we would better merely give end some default parameters, optionally looking like
class Foo
def bar
puts 'bar'
if foo
.... stuff....
endif
end def bar
end class Foo

Though that itself could lead to a few new problems. Still formatting errors that were detected at compile time wouldn't be too onerous.

The question is, how much work would any of these ideas be to implement, and what, if any, existing code would they break. (Offhand it looks simple and safe, but I'm no expert in THAT area.) Also, it it esthetically nice, though perhaps the importance of that is minimal, as one consideration is that all existing code should continue to work.

I feel that I'd probably continue to code a I currently do, except when an error was detected. Then I would find the greater simplicity in tracing it down to override any esthetic damage caused by the "excess" verbage.




Markus

10/8/2004 8:14:00 PM

0

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

> The question is, how much work would any of these ideas be to
> implement, and what, if any, existing code would they break.
> (Offhand it looks simple and safe, but I'm no expert in THAT
> area.) Also, it it esthetically nice, though perhaps the
> importance of that is minimal, as one consideration is that
> all existing code should continue to work.

parse.y comes with the source distribution.

It can be edited with any text editor.

I don't even know C and I was able to put together a patch that
makes lady's blush and strong men weep (see adjacent threads) in about
three light evenings work.

-- Markus




Randy W. Sims

10/8/2004 8:22:00 PM

0

Charles Hixson wrote:
> Peña, Botp wrote:
>
>> Randy W. Sims [mailto:ml-ruby@thepierianspring.org] wrote:
>> ...
>>
>> I'm only suggesting this as an option to ruby -c
>> like
>> ruby -c -check_extended_end
>> still we make endclass/enddef/endif synonyms to end, thus programmer
>> is free
>> to use them or not.
>> and w regards to indents
>> ruby -c -check_indent
>> Again, programmer is free to use indents (as syntax check) or not.
>> kind regards -botp
>>
> Perhaps they shouldn't be strict equivalents. I'd prefer that endclass
> NOT be able to close an if statement. But as long as the generic end
> statement was retained, then which variant to use could be a matter of
> taste and circumstance. And if we're going to go in that direction, the
> perhaps the class/routine name could be an optional parameter. This
> could result in something like:
>
> class Foo
> def bar
> puts 'bar'
> if foo
> .... stuff....
> endif
> enddef bar
> endclass Foo
>
> Or perhaps we would better merely give end some default parameters,
> optionally looking like
> class Foo
> def bar
> puts 'bar'
> if foo
> .... stuff....
> endif
> end def bar
> end class Foo
>
> Though that itself could lead to a few new problems. Still formatting
> errors that were detected at compile time wouldn't be too onerous.
>
> The question is, how much work would any of these ideas be to implement,
> and what, if any, existing code would they break. (Offhand it looks
> simple and safe, but I'm no expert in THAT area.) Also, it it
> esthetically nice, though perhaps the importance of that is minimal, as
> one consideration is that all existing code should continue to work.
>
> I feel that I'd probably continue to code a I currently do, except when
> an error was detected. Then I would find the greater simplicity in
> tracing it down to override any esthetic damage caused by the "excess"
> verbage.

I don't feel strongly about the issue as I rarely run into trouble since
I close a block immediately after opening it (free memory after
allocating, close filehandles after opening, etc). If Ruby were to be
extended, I would suggest that it be completely optional and only used
as a hint to the parser about the structure of the code. I like the form:

end [(class|module|def) [<NAME>]]

IOW, it applies only to high level blocks and is optional. Additionally
the name of the entity being closed can be named, the name of the
method, class, or module. whitespace seperates all elements.

I think it a simple and useful addition to Ruby.

Randy.


Joachim Wuttke

10/8/2004 8:26:00 PM

0

T. Onoma

10/8/2004 9:17:00 PM

0

On Friday 08 October 2004 03:48 pm, Charles Hixson wrote:| Or perhaps we would better merely give end some default parameters,| optionally looking like| class Foo |    def bar|         puts 'bar'|        if foo|         .... stuff....|        endif|     end def bar| end class Foo
I already do this:
class Foo    def bar         puts 'bar'        if foo         .... stuff....        endif     end #bar end #Foo
in much of my code for sanity sake. A -c check on those kind of remarks might do the trick, yes?
T.

Vote out Brendan Nelson

2/8/2008 2:43:00 PM

0

<snip>
>
> sounds like Satan the accuser, are you demon possessed
>
> Know. He just doesn't have his head up some religions ass!
>
>

you must be brainwashed by the fucken cult