You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Claude Brisson <cl...@savoirweb.com> on 2003/07/01 17:56:01 UTC

Re: Velocity Numerics [PATCH]

Nathan Bubna wrote :
> it would also be nice for maintaining some semblance of backward
> compatibility.  there was integer division before; there's no good reason to
> stop having one now.  also, it's an easier change to just switch from:
>
> #set( $foo = 5 / 2 )  to #set( $foo = 5 // 2 )  than to bother w/ intValue()
>

Another proposal to consider, that goes in the sense of backward compatibility (fully bc in fact) :

Only use '/', and make an integer division when implied numbers are both integers, floating point division otherwise.

Afterwards, intValue() and floatValue() can be used in some special cases : when you need a float result from two integers, or when
you need an integer result from two floats. But the default behaviour covers a wide percentage of standard cases.

One good point (but not a real argument, I know) is that java developers won't be surprised.

Yes I know, it is not very convenient to code this with the current implementation of the patch, since (if I understood well) all
numbers are converted to BigIntegers beforehand. But it is not a real argument either :-)

CloD



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Velocity Numerics [PATCH]

Posted by Claude Brisson <cl...@savoirweb.com>.
> It may make sense to
> programmers.  But the whole rationale behind this patch is that the typical
> template designer is not a programmer, and makes no distinction between 5
> and 5.0.

Yes, but, speaking of those typical template designers, have you considered the educational benefit in computing they would gain by
understanding the distinction between 5 and 5.0 ?

(and I am almost serious :-) )

CloD

----- Original Message -----
From: "Will Glass-Husain" <wg...@forio.com>
To: "Velocity Developers List" <ve...@jakarta.apache.org>
Sent: mardi 1 juillet 2003 18:21
Subject: Re: Velocity Numerics [PATCH]


> Hi Claude,
>
> Thanks for the thought, and appreciate your input.
>
> I think making 5 / 2 == 2 is a big mistake.  It may make sense to
> programmers.  But the whole rationale behind this patch is that the typical
> template designer is not a programmer, and makes no distinction between 5
> and 5.0.   Dividing 5 by 2 should always equal 2.5, unless the writer goes
> out of their way to specify the result should be an integer.
>
> Best,
>
> WILL
>
> ----- Original Message -----
> From: "Claude Brisson" <cl...@savoirweb.com>
> To: "Velocity Developers List" <ve...@jakarta.apache.org>
> Sent: Tuesday, July 01, 2003 8:56 AM
> Subject: Re: Velocity Numerics [PATCH]
>
>
> >
> > Nathan Bubna wrote :
> > > it would also be nice for maintaining some semblance of backward
> > > compatibility.  there was integer division before; there's no good
> reason to
> > > stop having one now.  also, it's an easier change to just switch from:
> > >
> > > #set( $foo = 5 / 2 )  to #set( $foo = 5 // 2 )  than to bother w/
> intValue()
> > >
> >
> > Another proposal to consider, that goes in the sense of backward
> compatibility (fully bc in fact) :
> >
> > Only use '/', and make an integer division when implied numbers are both
> integers, floating point division otherwise.
> >
> > Afterwards, intValue() and floatValue() can be used in some special cases
> : when you need a float result from two integers, or when
> > you need an integer result from two floats. But the default behaviour
> covers a wide percentage of standard cases.
> >
> > One good point (but not a real argument, I know) is that java developers
> won't be surprised.
> >
> > Yes I know, it is not very convenient to code this with the current
> implementation of the patch, since (if I understood well) all
> > numbers are converted to BigIntegers beforehand. But it is not a real
> argument either :-)
> >
> > CloD
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Velocity Numerics [PATCH]

Posted by Will Glass-Husain <wg...@forio.com>.
Hi Claude,

Thanks for the thought, and appreciate your input.

I think making 5 / 2 == 2 is a big mistake.  It may make sense to
programmers.  But the whole rationale behind this patch is that the typical
template designer is not a programmer, and makes no distinction between 5
and 5.0.   Dividing 5 by 2 should always equal 2.5, unless the writer goes
out of their way to specify the result should be an integer.

Best,

WILL

----- Original Message ----- 
From: "Claude Brisson" <cl...@savoirweb.com>
To: "Velocity Developers List" <ve...@jakarta.apache.org>
Sent: Tuesday, July 01, 2003 8:56 AM
Subject: Re: Velocity Numerics [PATCH]


>
> Nathan Bubna wrote :
> > it would also be nice for maintaining some semblance of backward
> > compatibility.  there was integer division before; there's no good
reason to
> > stop having one now.  also, it's an easier change to just switch from:
> >
> > #set( $foo = 5 / 2 )  to #set( $foo = 5 // 2 )  than to bother w/
intValue()
> >
>
> Another proposal to consider, that goes in the sense of backward
compatibility (fully bc in fact) :
>
> Only use '/', and make an integer division when implied numbers are both
integers, floating point division otherwise.
>
> Afterwards, intValue() and floatValue() can be used in some special cases
: when you need a float result from two integers, or when
> you need an integer result from two floats. But the default behaviour
covers a wide percentage of standard cases.
>
> One good point (but not a real argument, I know) is that java developers
won't be surprised.
>
> Yes I know, it is not very convenient to code this with the current
implementation of the patch, since (if I understood well) all
> numbers are converted to BigIntegers beforehand. But it is not a real
argument either :-)
>
> CloD
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org