Re: 'do JavaScript' still broken in Safari 3 beta
Re: 'do JavaScript' still broken in Safari 3 beta
- Subject: Re: 'do JavaScript' still broken in Safari 3 beta
- From: has <email@hidden>
- Date: Thu, 21 Jun 2007 16:05:11 +0100
On 21 Jun 2007, at 14:57, Mark J. Reed wrote:
Looks like something in the JavaScript interpreter has changed
from previous versions,
as "return 1" works fine in the version of JS used by Safari 2.
Unfortunately,
I'm not a JS expert (as you can tell) so I've no idea if this is by
design or accident - anyone know?
I assume it's by design. According to the standard (ECMA-262,
section 12.9):
An ECMAScript program is considered syntactically incorrect if
it contains a
return statement that is not within a FunctionBody.
Looks like. Whether that's a recent amendment or an older one that
Apple's JS engine has only just gotten round to supporting is
something I'm too lazy to check, but it certainly seems to answer why
'do JavaScript' wasn't returning the expected result. That it
returned no result at all is still a bug, although in this particular
case it's a bit secondary to the question of how JS errors get handled.
So there ya go. But if the JS interpreter horks on the string passed
to it from AS, it seems like the AS code should get an indication of
that...
In Safari 2, both compilation and runtime errors are simply squelched
and all that happens is that you get an empty string back. (No way of
telling if an empty string means failure or success, of course.)
Raising an AppleScript error would certainly be an improvement over
this, and while it's the sort of thing that really belongs under
'feature request', it may be worth folk submitting it as a bug report
on the off-chance that it gets taken more seriously.
I've never understood JS's approach to exceptions and exception
handling, so ain't going there myself. :p
It's pretty similar to Java's, actually. But the treatment of syntax
errors is somewhat implementation-dependent...
Out of interest, do you have any code examples that'd demonstrate how
to throw a runtime error in JS? Would be handy to include when I
finally submit a detailed bug report on this stuff.
Thanks for the info,
has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
http://appscript.sourceforge.net/objc-appscript.html
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden