skeeto / skewer-mode

Live web development in Emacs
The Unlicense
1.09k stars 57 forks source link

Questions about skewer.js/globalEval #40

Closed itegebo closed 10 years ago

itegebo commented 10 years ago

In looking at skewer.globalEval, and having read the perfectionkills article, I'm confused about a couple of things:

The first question stems from the article specifically calling out that construct as, "monstrous". It appears to be just another variant of indirect eval. What gives?

For the second question, I'm referring to those cases where some form of global eval exists, it just doesn't return a value. But the more I think about it, the more I realize this is perhaps trickier than I first thought. Has anyone run into an issue where the browser they wanted to skewer didn't support the current implementation of skewer.globalEval?

skeeto commented 10 years ago

This specific definition for globalEval was established in ac7e7bb as a solution for #14. The original indirect eval I was using wasn't working for Safari despite working everywhere else. If you can find an indirect eval that works correctly in all of IE8+, Safari, Chrome, and Firefox I'll use that instead.

I haven't run into a case where a global eval doesn't return a value. If that ever happened I doubt there's anything I could do about it. That browser would simply be incompatible with Skewer. This could happen someday if a major browser goes into strict mode only (i.e. no side-effect eval). The facilities wouldn't be there to support something like Skewer anymore.

skeeto commented 10 years ago

I just realized I didn't address your second bullet. That's actually a really good idea. I hadn't thought of that yet. The real difficultly would be in manipulating the original expression text to capture its return value. Fortunately we don't need it yet either.

itegebo commented 10 years ago

Okay, thanks for that. Sorry I didn't find #14 - I promise that I have been going through issues and trying to understand what's been done and why (I was going through the whole web sockets and long polling stuff). I got lazy and clearly didn't git/grep.

Regarding the non-result returning indirect eval case, the more I thought about it the more it seemed like more trouble than it's worth. In any case, I'd needed to read the perfectionkills article. Glad it was in there!

I consider this an answered question, feel free to close (or I will).