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.
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.
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.
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.
- Maxime
Afficher les réponses par date
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
On 2011-02-14, at 5:07 PM, Marc Feeley wrote:
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.
Are you sure that V8 removes everything? The following test says the contrary:
% d8 V8 version 3.1.1 [console: dumb] d8> var a = [1,2,3]; d8> a.splice(0); 1,2,3
Marc
On 2011-02-14, at 5:07 PM, Marc Feeley wrote:
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.
Indeed, Tachyon does not compare strings properly:
Tachyon initialization complete
Entering read-eval-print loop. Type commands below and press enter to execute them. For a listing of special commands, type /help To exit, type /exit
t> print("bbb" > "baaaaaaaa"); false
% d8 V8 version 3.1.1 [console: dumb] d8> print("bbb" > "baaaaaaaa"); true
Marc
String comparison isn't yet really implemented. Right now it probably compares the pointers. To be fixed.
However, what I meant is that in V8, the sort function seems to sort the numbers as if they were strings by default:
d8> a = [3, 4, 34] 3,4,34 d8> a.sort() 3,34,4
Are you sure that V8 removes everything? The following test says the
contrary:
% d8 V8 version 3.1.1 [console: dumb] d8> var a = [1,2,3]; d8> a.splice(0); 1,2,3
d8> var a = [1,2,3]; d8> b = a.splice(0) 1,2,3 d8> b 1,2,3 d8> a
d8>
- Maxime
On 11-02-14 05:20 PM, Marc Feeley wrote:
On 2011-02-14, at 5:07 PM, Marc Feeley wrote:
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.
Indeed, Tachyon does not compare strings properly:
Tachyon initialization complete
Entering read-eval-print loop. Type commands below and press enter to execute them. For a listing of special commands, type /help To exit, type /exit
t> print("bbb"> "baaaaaaaa"); false
% d8 V8 version 3.1.1 [console: dumb] d8> print("bbb"> "baaaaaaaa"); true
Marc
Tachyon-list mailing list Tachyon-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/tachyon-list
On 2011-02-14, at 6:07 PM, Maxime Chevalier-Boisvert wrote:
String comparison isn't yet really implemented. Right now it probably compares the pointers. To be fixed.
However, what I meant is that in V8, the sort function seems to sort the numbers as if they were strings by default:
d8> a = [3, 4, 34] 3,4,34 d8> a.sort() 3,34,4
OK. I fixed the default comparison function (but it will only work when string comparison works).
Are you sure that V8 removes everything? The following test says the
contrary:
% d8 V8 version 3.1.1 [console: dumb] d8> var a = [1,2,3]; d8> a.splice(0); 1,2,3
d8> var a = [1,2,3]; d8> b = a.splice(0) 1,2,3 d8> b 1,2,3 d8> a
d8>
OK. The problem is fixed.
I have put the unit tests in the right place, and done a push.
Marc
Thanks.
A slight detail. When doing conversions to string, you should probably do String(x) instead of x.toString(), because some values (eg: undefined) can't have method calls. I will change this in the array code.
- Maxime
On 2011-02-14, at 6:07 PM, Maxime Chevalier-Boisvert wrote:
String comparison isn't yet really implemented. Right now it probably compares the pointers. To be fixed.
However, what I meant is that in V8, the sort function seems to sort the numbers as if they were strings by default:
d8> a = [3, 4, 34] 3,4,34 d8> a.sort() 3,34,4
OK. I fixed the default comparison function (but it will only work when string comparison works).
Are you sure that V8 removes everything? The following test says the
contrary:
% d8 V8 version 3.1.1 [console: dumb] d8> var a = [1,2,3]; d8> a.splice(0); 1,2,3
d8> var a = [1,2,3]; d8> b = a.splice(0) 1,2,3 d8> b 1,2,3 d8> a
d8>
OK. The problem is fixed.
I have put the unit tests in the right place, and done a push.
Marc
Tachyon-list mailing list Tachyon-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/tachyon-list
On 2011-02-15, at 12:46 PM, chevalma@iro.umontreal.ca wrote:
Thanks.
A slight detail. When doing conversions to string, you should probably do String(x) instead of x.toString(), because some values (eg: undefined) can't have method calls. I will change this in the array code.
Interesting! OK.
For efficiency the conversion to string should be done in a prepass, but that can wait.
Marc