> On Tuesday, March 11, 2003, at 06:51 AM, Peter Romianowski wrote:
>
> >> I don't think FP would break existing templates if implemented with
> >
> > Unfortunately it does. #set ($foo = 5 / 2) will result in
> $foo being
> > 2.5 instead of 2.
>
> Well.... Try this :
>
> System.out.println(5/2);
It prints 2.5 ... No, just kidding :) The proposed patch would make
5 / 2 = 2.5 and that'd be the desired behavior (getting away from
Java-Number-Types)
Within Velocity I'd like to be able to use just *numbers* and I don't
want to hazzle around with Integer vs Long vs Float vs ... But I know
that this topic is really complicated since there is no "100% right" way.
And when all the introspection things comes in it get's even more complicated.
The basic question is: Is Velocity supposed to be a *Java*-Template
Language? If so, then things like casts *must* be implemented. If you
have all the type-stuff (Integer, Long, Double) available and you have
to handle it, you should be able to cast IMO... Until now Velocity does
a lot of things to overcome Java-Strictness, like accessing beans and
maps the same way. I mean if we distinguish between Integer, Long, Float
and so on, why don't we distinguish between Maps and Beans too?
> >
> >> care (although I don't see myself the necessity for them);
> but I just
> >> *cringe* at the idea of balooning the numeric types to
> >> BigInteger/BigDecimal's. It's just megaton-scale overkill.
> >
> > As said some times now: The final version will *of course* not use
> > BigInteger / BigDecimal for every operation. That'd be
> total overkill!
> > I just implemented the *first* version this way, because it
> was quick
> > to do and would deliver the most precise results. These
> results can be
> > achived with some if-Statements too and that will be done
> for a final
> > version (of course, again). My focus has been on correctness rather
> > than speed for the first version.
> >
> >> I'd say that any application sensitive enough to overflow to care
> >> should implement careful (pardon the redundancy) business logic
> >> outside
> >
> > That's for sure! But I really don't see why something like
> displaying
> > a progress bar ("10.23 % finished") would require any
> business logic.
> > Other things like displaying a total price should go into
> the business
> > logic or controller, since there might be rounding issues. For my
> > everyday use I find enough cases where I simply need numbers or the
> > possibilities
> > to compare floats. BTW, most people forget that with full number
> > support
> > you get short, byte and long-support too. I cannot count
> the number of
> > workarounds I had to implement because my business logic must use
> > longs :)
>
> I keep going round and round in my head about this. I keep wondering
> if there is a clean way to introduce this w/o breaking templates.
The easiest way would be to introduce new operators. But that might be
ugly. The only operator that raises real trouble is / AFAICS
If the /-operator thing is solved then there should only be problems
with code now working that hasn't worked before, like this:
($myLong is a Long)
#set ($myValue = 5)
#if ($myValue < $myLong)
..
#end
This code would raise a warning now but will work with number-support
included. I tend to think that these cases can be negelected. Another issue
is the overflow-handling. If we decide to implement it (if we get a way from
all the type-thing, then it *must* be implemented IMO) then perhaps
seldomly cases like:
($myValue = Integer.MAX_VALUE)
#set ($myValue = $myValue * 2)
In the current version this results in $myValue being -2 IIRC. In the new
version $myValue would be Integer.MAX_VALUE*2 and a Long.
Regards,
Peter
> geir
>
> --
> Geir Magnusson Jr 203-956-2604(w)
> Adeptra, Inc. 203-434-2093(m)
> [EMAIL PROTECTED] 203-247-1713(m)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]