[PATCH] templates: add substring and string length operations

Yuya Nishihara yuya at tcha.org
Fri Jul 14 23:18:44 EDT 2017


On Fri, 14 Jul 2017 19:50:34 -0700, Rodrigo Damazio wrote:
> > On Fri, 14 Jul 2017 16:27:49 -0700, Rodrigo Damazio via Mercurial-devel
> > > + at templatefunc('substr(text, start[, end])')
> >
> > I think substr() generally takes offset and length, not start:end range.
> 
> Yes, I considered that the start:end (like Python has) was more powerful
> because it allows negative numbers to reference the end, whereas offset and
> length needs to be calculated in those cases. Would you like me to switch?

start and offset can be negative anyway, though length can't. The name
'substr()' seems confusing if it takes start:end. Can you find another name
or switch it to take length?


More information about the Mercurial-devel mailing list