--
You received this message because you are subscribed to the Google Groups "Jsonnet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsonnet+u...@googlegroups.com.
To post to this group, send email to jso...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jsonnet/c88387c5-96dc-42e8-a88c-082fed8017f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
It'd b nice to support either exactly the same as python * and **, or something a bit simpler but equivalent, e.g.f(x, y, z, ...) with the ability to somehow access keyword args and regular args from the ... when you're inside the function. But then I don't know how you would call a function if you had an array / dict or both. Maybe it's not possible to do better than Python here? :)
On Sat, May 18, 2019 at 4:54 PM Stanisław Barzowski <stanislaw...@gmail.com> wrote:
I agree with Daniel that it could be really nice to have variable length argument lists. I really missed this feature when playing with parser combinators in Jsonnet - it resulted in a lot of noise from double parens like `seq([a, b, seq([c, d])])`. And I think variable length functions shouldn't be a problem in general. Splat is a bit more controversial since then it's unclear from looking at the code how many arguments are passed (which is not a deal-breaker, but a serious disadvantage IMO).
On Monday, 29 April 2019 17:56:14 UTC+2, Daniel Pittman wrote:
On Saturday, April 20, 2019 at 2:58:40 PM UTC-4, David Rees wrote:Is there a way to unpack a list into an argument lists to a function using the * (splat) operator like in Python?So instead ofselfAlias('a', 'b')one could doselfAlias(*['a', 'b'])Of course my actual use case is more complicated than that. I have a list of lists that I want to pass to a function based on the first item in each list. The functions take different arguments so I can't just explicitly unpack each list.In my experience real-world examples usually work better than hypotheticals.Anyway, I recently wanted the opposite of this: gather an arbitrary number of arguments into an array, for processing. Use case was a DSL for gmailctl; one of the examples from my configuration, plus my work-around for it:local _from(values) = std.map(function(item) {from: item}, values);local from(a, b=null, c=null, d=null, e=null) = _from(std.prune([a, b, c, d, e]);This supports this expansion:std.assertEqual(
To view this discussion on the web visit https://groups.google.com/d/msgid/jsonnet/CANarjTjTjsAQvbK9V08fp3NSLxvo3ye%2BO0y%3DFuj_%2B4fKdOmgkw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.