Closed Bug 642196 Opened 13 years ago Closed 13 years ago

GCLI should allow JS to be entered using {}

Categories

(DevTools :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jwalker, Assigned: jwalker)

References

Details

(Whiteboard: [minotaur][best:3d, likely:5d, worst:10d])

Previous developer tool command lines have been primarily JS based. While this is somewhat limiting, it does allow easy interaction with the DOM and JS data. GCLI should allow this access using something like the following:

> echo {window.title}
"Enter Bug"

> {console.log('hi')}
"hi"

It is expected that the command line will have a toggle switch to allow JS input to be the default.

The system will allow JS to be the default, allowing use of JS without either "{}" or the toggle switch:

> eval 2+2
4

The system may need integration with a JS parser like narcissus or uglify to allow us to recognize matching {}
Whiteboard: [estimate:best=3d,likely=5d,worst=10d]
Depends on: 653979
No longer blocks: GCLI-EXPERIMENT
Blocks: GCLI-FUTURE
Kind of a non-sequitor:

The ipython enhanced python shell uses `!` to distinguish shell commands from python code.

For example, this is interpreted as python:

    > foo = 5

and this would be a shell command:

    > !ls -al

Would it make sense to alias "eval" to "!"? I think "eval" is quite long, and though it is useful for learning the GCLI, as soon as you know it you want something more concise:

    > <normal commands>
    > !<arbitrary javascript>

Thoughts?
I suggested {} for 2 reasons:
- it allows something after the JS
- {} already has the notion of containment in JS.
{} is used for defining an object literal. Using it as a wrapper for code to evaluate could be confusing.

I'm not sure I like the ! notation either for a more modern shell either. That makes sense in a non-graphical environment like iPython (or Bash or whatever). It makes less sense in a "graphical" command line. Could we toggle Eval mode with a button + keyboard shortcut combo?
The confusion between {} for defining a block and for defining an object literal isn't *that* great though is it?

And wouldn't most web developers that are going to want to type JS into the command line already get the dual uses?
yeah, no doubt. It's just kind of a strange case of overloading.

Evaluating JS seems like it might be a special enough case that it could warrant some additional UI. Just a thought.
another alternative syntax that will make a bit more sense if this becomes spec:

{||} block syntax.

http://wiki.ecmascript.org/doku.php?id=strawman:block_lambda_revival

(or even {|} with no block arguments.

e.g., {| // some javascript }
Nice idea, thanks Rob.
Blocks: GCLI-JS
No longer blocks: GCLI-FUTURE
Assignee: nobody → jwalker
Whiteboard: [estimate:best=3d,likely=5d,worst=10d] → [minotaur][best:3d, likely:5d, worst:10d]
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.