I believe they’re referring to the fact that the integer
type has a maximum positive or negative value of 536,870,911 (which would make it a 30-bit value…); 64-bit values are needed in many places nowadays.
AppleScript actually has a double integer
class that should hold a wider range of values, but it’s not implemented properly & is not very useful.
(example of the only place I've ever used it)
to roundTo(n, decimal_places)
(* (number, integer) → number
Return n rounded to the nearest decimal position specified by decimal_places. Accepts negative decimal_places. If decimal_places is 0 or less, the return type is integer, otherwise it is real. *)
set rounded_n to n * (10 ^ decimal_places)
set rounded_n to rounded_n as double integer
set rounded_n to rounded_n * (10 ^ -decimal_places)
if decimal_places is greater than 0 then
return rounded_n
else
return rounded_n div 1
end if
end roundTo
roundTo(2.333444555666E+10, 0)
-- returns 2.3334445557E+10, rather than erroring out if "as integer" is used
A silly example here, perhaps, but I only came across double integer
because the above handler choked with a regular integer
.
For what it’s worth, I understand a lot of the sentiment here, but agree with Mark (and Hamish) that AppleScript doesn’t really have a viable future. It really is a pig of a language, and a lot of its “magic” comes from the first-class Apple Event support it receives from applications & its integration with macOS as a whole.
I think Swift would be the obvious way forward, if Apple was able to provide better support for scripting using Swift, with a proper Apple Event bridge, tooling, and some minor additions to the language that would take away the friction of using it for scripting (some sort of source “import” function, support for loading local swift packages similar to swift-sh
, a more permissive syntax mode, etc).
Proper Swift scripting support would at least address a lot of the pain points of AppleScript while waiting for Apple to get their automation strategy sorted (if indeed that ever happens). It would provide a clear path forward for those of us who love AppleScript for what it can do (even if we don’t love the language itself).