On 2011-02-14, at 4:53 PM, chevalma@iro.umontreal.ca wrote:
Erick finished support for the arguments object and I was able to get most of the array code working inside Tachyon. There are some basic unit tests in 'programs/stdlib_arrays/stdlib_arrays.js'. Not everything is yet tested as it will require support for apply.
Good!
I did encounter one strange thing. The behavior of Array.splice(0) on our system does the intuitive thing (removes nothing from the array). However, on V8, it removes everything from the array instead.
If I read the ECMAScript spec right, splice takes at least 2 arguments. So the behavior with one argument is probably implementation dependent. I wouldn't worry about it... unless we rely on splice(X) in the compiler itself.
Another place where we differ is that V8's default array sort function seems to do a lexicographical sort. However, the standard seems to say this is implementation dependent, perhaps because this decision was made with the help of a Ouija board.
The sort method that I implemented abstracts the test in a comparison function. The default is:
function array_sort_comparefn_default(x, y) { if (x > y) return 1; else return -1; }
By "lexicographical" you mean when comparing strings? In that case it is out of my hands... it will depend on the definition of x>y when x and y are strings.
Marc, if you have time, could you look into which behavior is correct and adjust our array code if necessary? If you need to make changes, please make sure to use the latest version on the repository as I made some changes to the code already.
For Array.splice -> no change, don't call splice on a single argument.
For Array.sort -> no change, it is > that might need to change.
Marc