Vector.sort()がダメすぎる件
ベクターのソートメソッドは、実装かマニュアルがおかしい。
たぶん内部でNumberをintに通してしまうミスをやってる。
adobeの人も間違うんだったら、いっそのことintにNumberを暗黙的に入れたらエラーってことにしたらいいのに
- forked:1
- favorite:14
- lines:37
- license : MIT License
- modified : 2011-04-25 21:59:12
Arrayも同様のようです
tamarinでも
http://hg.mozilla.org/tamarin-central/file/b0ee91f30435/core/ArrayClass.cpp#l957
971行目で
ActionScriptの関数の呼び出し結果を
toInteger()で整数に型変換しています
function (a:int, b:int):int {
return x > y ? 1 : (x < y ? -1 : 0);
}
とするのが良さそうです。
- by
9re
- at 2011/04/25 23:49:54
ECMA-262の仕様とは異なりますね
15.4.4.11 Array.prototype.sort (comparefn)には
If comparefn is not undefined, it should be a function that
accepts two arguments x and y and returns a negative value if x < y, zero if x = y, or a positive value if x > y.
とあり、comparefnは整数を返すとは書いていない。
なので、バグ・・・なのか?
- by
9re
- at 2011/04/25 23:55:02
https://bugzilla.mozilla.org/show_bug.cgi?id=532454
Explains some z-sorting problems I had with small scale models.
- by
yonatan
- at 2011/04/26 02:54:35
整数


