3 ms·
Just to pose the counter argument, is it that hard to move data between hashes and lists? In reasonable languages it is at most a single function call. Javascr
by lacker 18y ago
Just to pose the counter argument, is it that hard to move data between hashes and lists? In reasonable languages it is at most a single function call.
Javascript has eliminated many differences between arrays and hashes (objects) but this leads to many bugs. For example, you have a third-party library that adds a .toString function on every object. But you also have code that iterates over the keys in an array, and now that iteration code hits a "toString" key instead of just the array indices you expect. Admittedly you could blame this on the object-hash identification rather than the array-hash identification....
- joe_the_user 18y ago1) As others have pointed out, creating an ordered hash out of an array and unordered hashed takes doing. Conversion between (ordered) arrays and unordered hashes doesn't solve this problem. 2) By my previous reasoning, I think identifying objects and hashes is also the-way-to-go, once you can figure out for to do it correctly. Javascript clearly has some problems. One possible solution is having different functions to iterate different types of keys, so objects/members could be added without being seen by data iterators. Of course, I don't claim to have put all this is into the codified form it needs in order to form the basis of a language. I'll do that if and when I ever create a new language.