"Henning P. Schmiedehausen" wrote:
> 
> Jon Stevens <[EMAIL PROTECTED]> writes:
> 
> >However, you could modify the templates which generate the code and submit a
> >patch that makes it do what you want. You have the source code...
> 
> Yes. Then I would scratchy _my_ itch. And I could even simply put it
> into the CVS. And three weeks later, another developer with CVS write
> access would come along and say "hey, I need a Byte here. Not an
> Integer" and put a patch into the CVS. Rinse, repeat.
> 
> Having the source is fine. Having consent _why_ something does what it
> does is better IMHO.
> 
> And I completely agree with Geir, that simply checking "is this a
> number and the blindly calling intValue()" is not a good solution. But
> having to use
> 
> #if ( $data.Aktuell.intValue() > 0 )
> 
> because
> 
> #if ( $data.Aktuell > 0 )
> 
> produces an obscure error is bound to drive people to php.

I am not sure that would drive them to PHP.  Or if it did, it would be
because they hadn't seen PHP :)

They'd be back.

[Ob Apology : I am not trashing PHP here - it's a wildly successful
system ... :)]

> 
> Quote one designer: "But it is a number. It returns 0 to 2. So why
> can't I just use $data.Aktuell > 0 ?" Answering "because it is not an
> Integer but a Byte" produces a blank look in the best case.

One might argue that the 'data API' you are providing the designer is
broken, making them compare bytes to floats. (or whatever)
 
> The solution with intValue() solved my problem with the template in
> the Template engine. Not in the Peer object creation or the underlying
> web application, but at the point where I recognized the problem. And
> I'm not really sure about Geirs' example because in the case of
> 
> #if ($data.Float > 2.0)
> 
> this IMHO would still work because the check whether both objects
> are of the same type would catch this.

1) No - we don't do floating point in VTL - so the 2.0 wouldn't parse.
2) Even if we did (which we most likely won't - there is no real design
purpose - it will promote the movement of business logic / application
logic into the template)  you probably wouldn't have a naked number -
you would have another reference :

Because if you had something like

#if( $data.currentRation > $minimumRatio )

and they were both Doubles, the problem would crop up with the offered
int() solution.

> I, personally, would prefer to document the behaviour that "if the
> left and the right side of an #if() statement are not of the same Java
> object type, it is checked whether they're numerical types, and if
> yes, the comparisation is done with Integer values of these. If
> they're not of the same type and not both numerical types, a runtime
> error is reported". Because it would give us a documented behaviour
> that IMHO does not confuse the non-techie-guys.

No.  I think that it should work 'correctly'.  We just have to figure
out what that means :)  I also think we need to be careful to decide
just how big this problem is, and if we need to make Vel more language
like to solve it.  If you pay attention to my posts, you will note I
tend to be very conservative and try to drive to the minimum general
solution, pushing what we can into the app layer.
 
> And it is (basically) the same thing, that other languages like perl
> and php do and that is the IMHO the user base that is moving over to
> solutions like Velocity.

I personally try not to think of velocity as a language on par with perl
and PHP.  That's where I think the Java fits into this.  I think in the
template language, minimalness is key.  (I sometimes wonder if we have
gone too far in some places already.)  There is a hugely powerful
language on the 'other side' of the View-MC boundary...

geir

-- 
Geir Magnusson Jr.                           [EMAIL PROTECTED]
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Reply via email to