[getting OT ...] Re: [antlr-interest] exceptions in the lexer

matthew ford Matthew.Ford at forward.com.au
Tue Dec 7 11:13:17 PST 2004


Yes it may not work in some cases but in those cases that it does
you have allowed the user to save the work they have done and continue to
work using other areas of the application .
In the JEdit example, all this error means is that you cannot open that
particular file
as it is too large. Your existing edits are not dumped by a programmer who
is too lazy (timid?) to try and recover from errors.

In those cases where you cannot recover, what have you lost by trying?
What was the alternative to trying to recover?
Just shutting down the application and loosing all the user's existing work!
No merit points for doing that.  Your application will get a reputation as
being
unreliable.

I want to program robust applications.  I want to keep trying to recover
from
ALL Throwables untill the the JVM or the OS dies.
The user deserves as much.  If the JVM or OS dies as a result of an error
trying to recover does not make it worse.

Programming errors during the developement of my Parallel program
(www.forward.com.au)
regularly caused it to try and recovere from NullPointers, ArraysOutOfBounds
and
OutOfMemory.  These errors never shut the whole application down.

Java's advanced garbage collection means it is much more robust in the face
of errors then
previous languages.  But it seems programmers (and even the language
designers) do not
realize how robust it is.

In many cases you can sucessfully recover from Errors and RuntimeExceptions.

It is dissapointing that the text books have trained a generation of Java
programmers who
will not even try.

matthew
----- Original Message ----- 
From: "Harald Mueller" <harald.m.mueller at bigfoot.com>
To: <antlr-interest at yahoogroups.com>
Sent: Tuesday, December 07, 2004 9:56 PM
Subject: [getting OT ...] Re: [antlr-interest] exceptions in the lexer


>
> >
> > Well JEdit catches this and recovers.
> > Why can't I?
>
> You can :-) But there's no guarantee it works. Here is the text from the
JLS
> (section 8.4.4) - which I interpret as a more constructive comment than
> mine:
>
> > Exceptions that are represented by the subclasses of class Error, for
> example OutOfMemoryError, are thrown due to a failure in or of the virtual
> machine. Many of these are the result of linkage failures and can occur at
> unpredictable points in the execution of a program. Sophisticated programs
> may yet wish to catch and attempt to recover from some of these
conditions.
>
> Regards
> Harald M. Mueller
>
> > matthew
> >
> > ----- Original Message ----- 
> > From: "Harald Mueller" <harald.m.mueller at bigfoot.com>
> > To: <antlr-interest at yahoogroups.com>
> > Sent: Tuesday, December 07, 2004 8:48 PM
> > Subject: Re: [antlr-interest] exceptions in the lexer
> >
> >
> > >
> > > >
> > > > Hey, Just extend you user-defined exceptions from RuntimeException
and
> > > > throw
> > > > them.
> > >
> > > He explicitly didn't want to do this - but I also do it (using a
> > > WrappingRuntimeException which I need at other places anyway (e.g. for
> > the
> > > Runnable.run() method)).
> > >
> > > > You catch all your RuntimeExceptions don't you?
> > > > Remember OutOfMemoryException is not necessarly fatal.
> > >
> > > This is not an Exception, but an Error - you would never catch this.
> > >
> > > Regards
> > > Harald M. Müller
> > >
> > > > matthew
> > > > ----- Original Message ----- 
> > > > From: "Paul J. Lucas" <pauljlucas at mac.com>
> > > > To: <antlr-interest at yahoogroups.com>
> > > > Sent: Tuesday, December 07, 2004 11:10 AM
> > > > Subject: Re: [antlr-interest] exceptions in the lexer
> > > >
> > > >
> > > > >
> > > > > On Mon, 6 Dec 2004, Terence Parr wrote:
> > > > >
> > > > > > Are you familiar with the filter option on the lexer grammar?
> > > > >
> > > > > Yes in the sense that I've read that bit of the documentation,
> > > > > but I've never used it.
> > > > >
> > > > > I don't want my entire lexer to be a filter since I need it to
> > > > > be a real lexer for a parser.
> > > > >
> > > > > My particular case at hand is dealing with pragmas that can
> > > > > appear anywhere comments can.  Since comments are most easily
> > > > > handled in the lexer, I handle pragmas there to for the same
> > > > > reason.  The problem is what to do if there's an error in a
> > > > > pragma.  The lexer can't throw user-defined exceptions.  (I
> > > > > might be able to work around it by hiding the real exception
> > > > > inside a Runtime exception, but that's ugly.
> > > > >
> > > > > - Paul
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Yahoo! Groups Links
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > > Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > > -- 
> > > NEU +++ DSL Komplett von GMX +++ http://www.gmx.net/de/go/dsl
> > > GMX DSL-Netzanschluss + Tarif zum supergünstigen Komplett-Preis!
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
> -- 
> GMX ProMail mit bestem Virenschutz http://www.gmx.net/de/go/mail
> +++ Empfehlung der Redaktion +++ Internet Professionell 10/04 +++
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list