I'm not sure I see a downside to including this (ability to compare numbers and Strings). Template designers are not programmers. When they hit problems (particularly those involving types), it'd be nice if most things just worked.
I can see a few counter points. It won't work well for formatted numbers (and only for internationalized numbers in the current locale). And it's not a common use case (as a few have pointed out) to compare 4.0 > "4.0". If we include my TemplateNumber proposal, then the developer can always wrap a String with an adapter that implements TemplateNumber so that it is properly comparable. Thus, (personally), I don't need this feature that badly.
But as I say above, I don't see a big downside to including it. Some might say... If you don't want it, don't use it.
Let's not get in a big flame war here. We've heard from Jonathan and John.
I wouldn't think that my vote counts, of course. I'm not really part of this community. I'm lead developer of a competing template engine.
That said, if you respect my opinion, and you want to know what semantics I would propose in a given situation, you hardly even need to ask me or wait for me to chime in. You can just look at how the template engine that cannot be named does it and that will give you an idea of what I think the right way of going about things is...
Regards,
Jonathan Revusky -- lead developer, FreeMarker project, http://freemarker.org/ FreeMarker-Velocity comparison page, http://freemarker.org/fmVsVel.html
Any comments from others?
Best, WILL
----- Original Message ----- From: "John J. Allison" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 25, 2003 3:54 PM
Subject: Re: Velocity Numerics [PATCH]
Jonathan Revusky wrote:
I know that perl automatically coerces numbers into strings in these spots, and I recognize that it "works" as far as that goes.
However, that does not tend in any way to alter my opinion that it's a terrible idea.
Yeah, but it works so well in Perl that nobody cares that it's a bad idea (like a lot of stuff in Perl). (I don't follow perl-dev or whatever, maybe it's actually a big issue for them.) And Perl does have different operators for numbers and strings which makes things clearer.
Auto-coercing strings to numbers could contribute to Velocity's usability rather than having to use syntax like
#set ($foo = 42) $foo.parseInt($bar)
It gets quite useful when template writers can't influence the API of the Java objects they're referencing (even via subclassing a wrapper) and are stuck with toString() or equivalent when at least sometimes they know the string represents a number.
Of course that still doesn't mean it's a good idea for Velocity, and I don't immediately see where *I* would write code that requires this coercion. :)
John Allison [EMAIL PROTECTED]
--------------------------------------------------------------------- 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]
