On Thursday 03 May 2007 7:09 pm, Mark Mills wrote:
> Shouldn't list.pick be list.rand? Or, list.rand should be a synonym for
> .pick(1). Heck, I'd like hash.pick or rand too.

I originally had list.random.  The problem is that it conflicts to much with 
text.rand which does what the perl function rand does.  I chose pick because 
that is up and coming in Perl 6.  It picks a random item out of a junction 
(I'm not sure if it has generally been applied to arrays in Perl 6).  I 
thought it was short and applicable.

> I love list.int. Love.

I think you mean text.int.  I'm not sure what list.int would do.  It is 
probably my fault for using "text." and "list." to refer to whether it is a 
Text or List VMethod whereas in TT "text." and "list." could be any type of 
variable.

> I've added that (aka .round, .floor, etc.) and 
> some variation of rand and pick to just about every TT thing I've done.

Well - I think the fmt method takes care of round (assuming you like Perl's 
rounding behavior).

   [% number.fmt('%d') %]    # Round to integer
   [% number.fmt('%.1f') %]  # Round to one decimal place (etc)

> Of course, now someone will want ".cast". :)

Well, you sort of have it now - there are list, and hash methods for each of 
the various types.  With .fmt you can pretty much get the cast to Text for 
each of the types also.

> If not in TT2, then TT3 for this one.

If you try CGI::Ex::Template you can have it today.


Paul

_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to