Re: Quick note about future number handling
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Saturday, March 20, 2010, 3:15:15 PM, Daniel Dekany wrote:
> Saturday, March 20, 2010, 9:53:56 AM, Tom Fennelly wrote:
>
> [snip]
>> Hi there.
>>
>> If you wanted to maintain backward compatibility, perhaps you could
>> leave the default as is and provide a method on the
>> Template/Configuration instance for overriding the default formatting.
>> Could also do same with a new computer readable default, allowing
>> existing users to override the default back to the old human readable
>> default (which I've also found to be a total PITA :) ).
>>
>> In fact.... would this be nice to have for all types... including Dates
>> etc e.g.
>>
>> configuration.setDefaultFormatting(Number.class, "c");
>> configuration.setDefaultFormatting(Date.class, "string('yyyy-MM-dd')");
>> // etc...
>
> You mean, the computer-readable date format should be the ISO format?
> Maybe. Too bad you will still need to use ?date/?time/?datetime unless
> the date comes from JDBC.
>
>> Actually ... just looked at the API and it appears to already be there
>> on the Configuration class i.e. setNumberFormat(String) and
>> setDateFormat(String) :) Why did I never see that before :)
>
> Well, that thing (also known as the "number_format" setting) is
> demonstrated at many places. Anyway... it's not what we need there.
> Number format sets that format for *human* audience, and that should
> remain so. (You can't easily enforce computer-audience format there...
> for starters, the decimal separator may magically becomes from "." to
> "," in some locales, like in mine. Then, if you use number format for
> that, what is left for human-audience formatting then?) What we should
> add is a setting like "default_audience" (setDefaultAudience), which
> could be either "computer" or "human" (AUDIENCE_COMPUTER,
> AUDIENCE_HUMAN).
>
> But... it doesn't really solve the whole problem about
> backward-compatibility. Even if we put aside the cases where templates
> from different sources are used together (some was designed with
> default_audience="computer" in mind, but some with
> default_audience="human"), just think about how much confusion it will
> generate. To be on the safe side, you had to specify the audience
> everywhere... /-:
Plus, it has to be lexically-scoped setting... like "strict_syntax".
Then at least you can mark old templates with <#ftl
default_audience="human">.
> Anyway, we might still will have to do this. First
> introduce the default_audience setting, then in 3.0 change its default
> value to "computer".
>
>> Regards,
--
Best regards,
Daniel Dekany
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev