Re: ?floor ?round ?ceiling in 2.3 and 2.4 now:[WAS Re: weird macro params issue]
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Monday, May 5, 2008, 6:43:57 PM, Klotz, Leigh wrote:
> Daniel,
>
> Thank you! Here are some replies inline:
>
>> I think they rather should be under the numerical built-ins, because
> at least ?round is not something that I feel to be an expert stuff.
>
> I'm happy to have left that decision to you.
>
>> Ceiling and floor is certainly a bit esoteric, but whatever... expert
> stuff rather meant to be stuff for IT/programming "experts", like ?byte
> or even ?interpret. So I have moved these over.
>
> The request for ceiling came from a UI designer, not a programmer.
> Here's the use case for ceiling and floor. Round was there just because
> it's part of the set. Here's some quickly-typed code that shows how
> they're used, so you can see why ?round isn't correct for either case:
>
> <#assign pageCount=(itemCount / itemsPerPage)?ceiling />
> <#assign pageNumber=(itemNumber-1 / itemsPerPage)?floor />
> <p>Page ${pageNumber} of ${pageCount} | <a
> href="view?itemNumber=${itemNumber+itemsPerPage}">${pageNumber}</a></p>
Well, at least ideally, pageNumber and pageCount and like rather
shouldn't be done in the template, but being part of the data-model.
Not always feasible to do so though...
> While it's generally considered cheaper to use the floor version of
> divide, the savings would be in the noise in FM.
>
>> > I couldn't find the documentation for the 2.4 but maybe I overlooked
>
>> > it. docgen is there, but there is no content.
>>
>> It has a lot of content; something went wrong on your side. BUT, don't
> suffer with that... I will forward port it, with the other changes I
> made.
>
> I see now with the svn update that in the svn head the documentation is
> all in one big XML file whereas in the 2.3 branch it's in multiple
> files.
>
>>
>> I wonder why is this called ?ceiling instead of ?ceil, when the other
> one is ?floor, not ?flooring.
>
> Being born in an English speaking country has its advantages and its
> disadvantages.
Disadvantages, like what? :)
> One of the disadvantages is that I can't tell you why
> it's ceiling and floor. "ceil" just isn't a word.
(Um... according to my dictionary it *is* a word... only it's a verb.)
> If you're in a room, the room has a ceiling and a floor, not a
> ceiling and a flooring.
(I had the confused idea earlier that the nouns are ceil and floor,
not that they are ceiling and flooring... whatever.)
> I can't tell you why. (I don't speak Hungarian, but I do speak
> Japanese...)
You worked there?
> Mathematica sensibly calls their function "ceiling":
> http://mathworld.wolfram.com/CeilingFunction.html
> You may be alluding to Java, which calls it "ceil":
> http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Math.html#ceil(double)
> I think the Java version dates from a time when they liked abbreviations
> (cf. pow, rint).
OK, so it will be "ceiling", of course.
> Leigh.
--
Best regards,
Daniel Dekany
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone