bug-recutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC] Expanded language for templates


From: Antoine Kalmbach
Subject: Re: [RFC] Expanded language for templates
Date: Fri, 18 Dec 2020 15:23:06 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin)

This is really good. Few comments regarding looping. It think it could
be useful to have a way to enumarate the current array index using a
special tuple binding like this:

{{@for (A, i) 1..5}}
  {{i}}. {{A}}
{{@end}}

Since otherwise the RFC does not have facilities for variable
assignment, I can't think of a way to do this otherwise, except using
field subscripts.

Second comment: is there a need for a separate foreach keyword? It looks
to me that just 'for' is enough, since the expressiveness of both
constructs are more or less the same.  Ranges like A..B could return a
structure that can also be addressed by for, or rather, make one general
looping keyword that works on any kind of iterable structure, regexp,
records, etc.

Third: stepping. Something like

{{@for a A..B:2}}
{{@end}

Would iterate every 2nd element from A..B. Come to think of it, if -1 is
the step, then you could get reversed iteration. I think Python slicing
works like this. But perhaps it is wise not to throw the kitchen sink
into the mix.

-- 
Antoine Kalmbach



reply via email to

[Prev in Thread] Current Thread [Next in Thread]