News for hackers. Stuff that matters.
Re:Making Map Operations Implicit in Programming by dragonwriter on Tuesday December 17, 2013 @11:18AM (#6921908)
The problem I see is that implicit mapping restricts the scope of operations that can work on collections -- if there is no distinction between applying an operation to an single object and applying the same operation to all members of a collection, then no collection can directly support the same operation as anything which might be a member of the collection, because you can't disambiguate between attempts to operate on the collection and attempts to operate on the members.

This would seem to be a problem in general, and a particular problem for nested collections. Explicitness makes intent clear.

Re:Making Map Operations Implicit in Programming by farginay on Wednesday December 18, 2013 @12:41PM (#6929055)
It's interesting to see how the array programming languages have handled this. The way it works (loosely) is that everything is an array. A scalar is kind of a degenerate array, and a vector is an array of rank 1. Matrices can be seen as arrays of arrays of arrays..

Each operator defines its extent. The count operator '#' in J works at the top level. If you have a 3 x 4 matrix, it returns 3. Take '{.' works the same way. If you have a 3 x 4 matrix and you take 1, you will get a 4 element vector which is the first row of the matrix.

Something like decrement '<:' applies to all of the elements in a matrix regardless of the dimensionality.

This isn't like OO where collections have operations attached to them.