Permalink
Context, metadata, and zip()
04 DEC 2003
Sjoerd Visscher writes:
[referring back to another article on the importance of context]
I completely agree. In fact, it's exactly the issue I have with functional programming. Take for example the function zip (or zip3, zip4, exponential ugh-ness), a very popular function in f.e. Haskell. Firstly, if you have two lists, with values that go pairwise together, those values shouldn't have been apart in the first place. Secondly, what you end up with is a list of tuples. Values in a tuple always have more context than just being together. All this information is lost.
It seems to me that zip provides a useful service. How is
listOfTuples = zip(listOne, listTwo)worse than this:
listOfTuples = [] for i in range(min(len(listOne), len(listTwo))): listOfTuples.append(listOne[i], listTwo[i])If this is going to be an argument against allowing anonymous tuples in a language, fine. I don't see what this has to do with functional languages or
zip(), though.
That this issue is completely lost on the functional programming world is very apparent from the research.They're mostly focussing on structural typing, so this makes sense.
The holy grail seems to be a generic map on any data structure. But in practice any data structure more complex than a list, is bound to have some meta data. A generic map would map a function over the data and the meta data at the same time. That's almost never usefull. Obviously this encourages the use of a separate data structure for meta data, pulling that data out of context.I don't think I follow this at all. Maybe examples would help.
XML has already a nice solution for this. XPath is a very simple syntax for building generators. Esp. the axes (ancestor::*,following-sibling::* etc.) are a nice way of iterating over XML in a specific way/direction. That way it's easy to map a function over a specific part of the data structure.I'm still not getting it. What is it about functional programming that discourages traversing a data structure in a specific way or direction? I'm mostly confused here. Maybe Sjoerd will write some more (with examples :-), to explain what functional programming has to do with this. Is the argument just "it's bad to use anonymous tuples instead of creating named classes/records/whatever?"
Update: Sjoerd clarifies.
