[PATCH] templates: add substring and string length operations

Martin von Zweigbergk martinvonz at google.com
Fri Jul 14 23:40:36 EDT 2017


On Jul 14, 2017 8:19 PM, "Yuya Nishihara" <yuya at tcha.org> wrote:

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?


Maybe Python calls it slicing? So slice() might be okay.

_______________________________________________
Mercurial-devel mailing list
Mercurial-devel at mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170714/8c6b33e6/attachment.html>


More information about the Mercurial-devel mailing list