Larry Wall larry-at-wall.org |Perl 6| wrote:
On Tue, Jun 02, 2009 at 08:21:29AM -0700, yary wrote:
: I do see a problem if there's more than one unspecified dimension.
: Though I suppose an array of shape(*;*) as an lvalue might be a
: constraint allowing assignment only of another 2D array?

I don't see why we shouldn't use the capture shape of the value
by default all the time, and do linear reshaping only if the value
comes in as a flat list.  We've gone to some pains to allow ephemeral
shaping of values through captures, and it seems like it's good error
checking to check the shape of the value against the shape of the
container unless explicitly defeated.

That is to say, if you erase the capture shape by putting the value
into list context, it linearizes it, and then the container knows
to reshape.  Otherwise the container attempts to use the value slicily.

Larry


Consider:

   (@a,@b...@c) = SomeCapture;

The first container, @a, being fixed-size will grab some of the elements. Now, what's left in SomeCapture is not even starting at a top-level boundary in the original structure. It's in the middle of some list some number of levels down. How does what's left of the capture imply the proper shape?

It also means that given a multi-dim array, or a [**] array that can hold any morphology, the right-hand-size can't be a normal return from a map or whatever because you'll get the structure from _that_. The shape of the list is generally determined by the definitions of function return and looping statement semantics, and can't be used to formulate the structure you wanted.


As it stands, list assignment is "list context" for the RHS. That is wise. If the Capture Revolution comes to that, it needs to be carefully thought out.

--John

Reply via email to