[Swift-devel] Re: fixed_array_mapper versus array_mapper on output

Ben Clifford benc at hawaga.org.uk
Sat Feb 12 17:10:16 CST 2011


> I know that we used the fixed array mapper to allow returning arrays
> from an app. It's isStatic() returns true, whereas array_mapper's
> isStatic() returns false. So perhaps it's a matter of making
> array_mapper "static".

Perhaps. The array specifying the mappings is always known beforehand so I 
don't think that should break anything conceptually.

To elaborate on my previous comment in other email:

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