On Mon, 16 Dec 2019, Sven Schreiber wrote:
Hi,
quite often in some packages we just want to quickly copy a bunch of
objects into a bundle, and the names (keys) of the objects can stay the
same. How about adding a shortcut syntax do the defbundle function which
makes that possible?
The idea is that if just the first argument (a string) is provided
(which would up to now be illegal) it would have to be a separated
string with all object labels.
Example:
bundle b1 = defbundle("A,m,someobj")
would be equivalent to:
bundle b1 = defbundle("A",A, "m",m, "someobj",someobj)
Sorry to be a spoilsport, but to me this looks like hard-to-explain
alternative syntax (thinking of the doc for defbundle). I know it's
a little more verbose, but one can do:
<hansl currently-works="true">
bundle b1 = defbundle("x", 13, "m", I(3), "s",
"foo")
bundle b2 = null
loop foreach i x s -q
b2["$i"] = b1["$i"]
endloop
</hansl>
And now that we support "foreach" for arrays of strings this
approach also works with silly keys:
<hansl>
bundle b1 = defbundle("x", 13, "m", I(3), "silly key",
"foo")
bundle b2 = null
strings S = defarray("x", "silly key")
loop foreach i S -q
b2["$i"] = b1["$i"]
endloop
</hansl>
Allin