On Tue, 14 Mar 2017, Allin Cottrell wrote:
On Tue, 14 Mar 2017, Sven Schreiber wrote:
> Hi,
> is this failure expected or/and a bug?:
>
> <hansl>
> matrix m = I(2)
>
> strings ms = defarray("a", "b")
> colnames(m, ms) # works
> print m
>
> colnames(m, defarray("a", "b")) # fails
> print m
> </hansl>
I wouldn't really say it's a bug. As things stand defarray() needs a type
specification, so we know what sort of array the user wants and can check the
putative elements for type-correctness.
In principle, I suppose that if we didn't get a type specification in advance
we could evaluate all the putative members and if they're all of the same
(acceptable) type, set the array type afterwards.
Well, it turned out that was quite straightforward to implement, so
it's now in git. Anonymous usage of defarray() was not a use-case that
had occurred to me, but no real reason why it shouldn't work.
This also means that, e.g.,
M = defarray(I(2), {1,2,3})
will now work to give you an array of matrices without having to
specify the "matrices" type. However, the array() constructor still
requires a type specifier. You can't create an array of unspecified
type: the specification must either come up front or be implicit in
the set of arguments (defarray only).
Allin