Changing the use of eval() is sound, although as a word of warning,
I've found in the past that this is an area that's extremely hard to
change without breaking existing plugins on some browser or another
(sometimes quite subtly). In the past, we did at one point try a
slightly different approach of something like:
window.eval("function() {" + tiddler.text+ "}();");
The idea was to better isolate plugins, and also to enable them to
return an exit code via the 'return' statement. As I recall it, we had
to pull the change quickly to accommodate one or the other of the
clunkier browsers (probably Safari).
This time around, if we're going to change this, I guess it just needs
to be as part of a reasonable beta programme.
Cheers
Jeremy
--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com
I have taken the liberty of doing so:
http://trac.tiddlywiki.org/ticket/443
It's classified as a defect for now - not entirely sure whether that's
correct. Same with the priority and severity of this issue.
-- F.
Indeed - "tiddler" and "place" would be immensely powerful tools to have
in that context!
> I've just added a new CoreTweak at TiddlyTools that extends the core's
> invokeMacro() function to automatically set these two global variables
> [...]
> I think this might be a good candidate for inclusion in the core...
I agree, and have thus created a ticket and patch for this issue:
http://trac.tiddlywiki.org/ticket/444
The patch is entirely based upon Eric's code, but I'm not sure whether
my implementation is correct - so a quick review would be welcome.
-- F.
D'oh! That's a remnant from copying your code into my working copy.
I've fixed it now - thanks for the reminder!
-- F.
FWIW, I agree.
Just out of curiosity:
This whole discussion, and the backwards compatibility issues in
particular, seem to revolve around the anonymous function.
What about the alternative solution though, using
eval(tiddler.text, context);
as suggested by Liyang, and elaborated on by Saq:
> Instead of using window.eval, couldn't we call eval using call or
> apply and thus pass it the correct scope, i.e. window?
Or is that basically the same?
-- F.
Cheers
Jeremy
--