JonyEpsilon / gorilla-repl

A rich REPL for Clojure in the notebook style.
http://gorilla-repl.org
MIT License
887 stars 104 forks source link

Pre-evaluation when loading a worksheet? #112

Closed gfredericks closed 10 years ago

gfredericks commented 10 years ago

We're experimenting with using gorilla at work and trying to noodle around the difference between what we think it should do and what it actually does.

One of those differences is that nothing is evaluated when loading a worksheet, so any expression that depends on the results of others will fail until the dependent expressions are evaluated.

The question is if there's any way to approach this that isn't terrible.

One idea I had is a metadata-driven opt-in approach, document in this proof-of-concept commit: https://github.com/gfredericks/gorilla-repl/commit/bcf309c9d8699b8ae9aa24fecbd85752fa7ed856

gfredericks commented 10 years ago

We've realized this will probably be more robust implemented on the client side.

JonyEpsilon commented 10 years ago

I think I agree that this is probably a client side thing. I'm in favour of implementing #93, which would go some way towards what you're suggesting. We could also consider having a global flag to trigger worksheet evaluation on load.

One situation I'd like to avoid is having worksheets that auto-evaluate themselves without the user explicitly asking for it, as this could be used to cause trouble. It would be nice if one could open any Gorilla worksheet without worrying about what it might do to your computer (obviously it could do anything once you run it, but I'd like to be able to just open it with impunity). And I think I'd prefer for this behaviour to be default, not opt-in.

Perhaps a URL parameter would be an easy way to implement this?

JonyEpsilon commented 10 years ago

For reference, Mathematica uses cell-level metadata to identify cells that should be evaluated on notebook load (they are called "initialisation cells"). The application prompts the user when the first evaluation is made in a notebook as to whether it should evaluate the initialisation cells first.

I'm not sure I really like this behaviour though.

JonyEpsilon commented 10 years ago

There's an "evaluate all" command now, which makes it quick to re-run a whole worksheet. Don't think there's much to be gained by having an auto-evaluate option, and it keeps it simple, so am going to close this one.