[Mono-dev] [PATCH] Int32.Parse
Zoltan Varga
vargaz at gmail.com
Fri Oct 21 06:59:16 EDT 2005
Hi,
This looks cool. I think it would be easier to add an out ex
argument to CheckStyle
as well, instead of duplicating the exception message in three different places.
Zoltan
On 10/21/05, Carlos Alberto Cortez <calberto.cortez at gmail.com> wrote:
> Hello,
>
> Ok, then let's keep as you said. The attached patch applies what you
> suggested, and also added a method to retrieve the so-often-used
> FormatException (I think it was kind of insane to have the exception
> being thrown from different places with exactly the same message).
>
> Carlos.
>
> El jue, 20-10-2005 a las 13:06 +0200, Zoltan Varga escribió:
> > Hi,
> >
> > I think it would be a little bit easier to return the actual
> > exception to be thrown from the
> > TryParse methods as an out argument, instead of adding this
> > abstraction layer which
> > cannot return more helpful exceptions messages like "Number '123' is
> > not valid". We should
> > also retain the tryParse argument so these exception objects are not
> > creared if it is true.
> >
> > So for example:
> >
> > internal bool Parse (String number, bool tryParse, out int result, out
> > Exception ex)
> > {
> > ...
> > if (something_is_wrong) {
> > if (!tryParse)
> > ex = new ArgumentException ("....");
> > return false;
> > }
> >
> > Zoltan
> >
> > On 10/20/05, Carlos Alberto Cortez <calberto.cortez at gmail.com> wrote:
> > > Hey,
> > >
> > > Currently the Int32.TryParse method calls the Int32.Parse method, and
> > > catches the exceptions. That's not the best behaviour, since
> > > Int32.TryParse is designed to avoid the performance problems associated
> > > with exception handling.
> > >
> > > The attached patch proposes an approach to keep the result of the
> > > parsing as an enum, and based on it the methods decide whether they
> > > throw an exception or not.
> > >
> > > I wanted you to take a look at it, since we need to decide the best
> > > solution for this before changing the TryParse/Parse methods in other
> > > types.
> > >
> > > Carlos.
> > >
> > >
> > > _______________________________________________
> > > Mono-devel-list mailing list
> > > Mono-devel-list at lists.ximian.com
> > > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> > >
> > >
> > >
> > >
>
>
>
More information about the Mono-devel-list
mailing list