Compatibility issues
In some rare cases, you may get different results between the versions of the compilers.
Issues encountered so far...
Scriptol JavaScript vs. Scriptol PHP
- Comparing two arrays for equality gives the same results in the two languages. But if you compare them for inequality, the two languages applies different logics. PHP compare the number of items first, the array with less items if smaller than the other, but it is not the case in JavaScript, which compare the two first items, and other items only if the two first are different.
You can solve the problem like thus: To compare the array A and the array B for inequality, write:if (A < B) or A.size() < B.size()
That will works on the two backends. - Array may only be compared alphabetically in JS, even if all items are numbers. Build your own function to compare them numerically.
- Sorting an array with mixed content, strings and numbers, has different results in JavaScript and PHP. This compatibility issue can not be solved and so mixed array should be sorted with a user function.
- If you use number, even between quotes - as key of a dict, JavaScript inserts this keys before alphabetical keys, will PHP add them at the end. It is recommanded to not use numerical keys in a dict.
- When a substring is searched and not found in a string, PHP returns false while JavaScript returns -1. To have a compatible code, use nil:
var check = str.find("substr") if check = nil let ... do something ...
- Some minor features are delayed in the JavaScript version, because I am waiting for a more complete implementation of ES 6 in the V8 compiler. Iterators for example, and Map which is implemented but available only through an option.