[Swift-devel] Re: fixed_array_mapper versus array_mapper on output
Mihael Hategan
hategan at mcs.anl.gov
Sat Feb 12 17:31:04 CST 2011
fixed_array_mapper, through the syntax it uses for files= guarantees
that the number of elements in the array, and their names, are known
when an app is ready to run.
Can the same be said about array_mapper? I believe that it would not
make sense to allow an app returning an array mapped with array_mapper
to run before the respective files= array parameter to the mapper, as
well as all its elements, are closed.
While that may work in theory, I'm afraid that the way things are
implemented right now does not blend with that idea very well. The only
place where isStatic() is used is in RootDataNode.checkInputs(). I
believe that the array_mapper would work in Allan's scenario if,
somehow, the closing of the files= parameter would also cause the mapped
array to close.
On Sat, 2011-02-12 at 23:10 +0000, Ben Clifford wrote:
> I think the example allan gave, specifying a literal array as a parameter
> to the mapper, did not used to work - I think you could not specify such
> array literals arbitrarily. You could only specify them in an assignment
> statement. They were a specialised assignment syntax, rather than a simple
> "lvalue = rvalue".
>
> At some point, I think I made array literals possible as first order
> values anywhere you could put an expression. That change meant (amongst
> other things) that the example that Allan gave became valid.
>
> So when array_mapper was introduced, before real array literals, it was
> complementary to the fixed_array_mapper. The latter you could pass a
> literal string to, whilst the former you had to name an array that already
> existed somehow - you could not specify a literal array value in the
> mapper parameter. You could define "myarray" somewhere else and give it
> some elements, and then specify files=myarray, but you could not specify
> myarray=["one","two"].
>
> The introduction of array literals made array_mapper able to take literal
> mappings in the mapping expression without needing to separately declare
> an array variable and populate it - at that point, fixed_array_mapper
> became pretty much redundant.
>
More information about the Swift-devel
mailing list