maria icon indicating copy to clipboard operation
maria copied to clipboard

[nice to have] smarter handling of `load-gist` with eval=true / share

Open plexus opened this issue 7 years ago • 1 comments

Having load-gist, load-js and load-npm is super cool, e.g. I created this little "piano" with Chris Ford's cljs-bach.

https://dev.maria.cloud/gist/da20602e3eef7cf1e9b45a13884da972

This works if you evaluate the forms one by one, but if you use it with eval=true, it doesn't work, because it doesn't wait for the gist to load before evaluating the subsequent forms.

https://dev.maria.cloud/gist/da20602e3eef7cf1e9b45a13884da972?eval=true

This is presumably also why sharing this doesn't work. This is all not very surprising, but it would be super cool / nice to have to

  • have eval=true be smart enough to wait for the gist to load before continuing
  • have the shared version actually pull in the gist as part of the compilation
  • have load-gist detect when a file starts with an ns form, and switch the ns back to maria.user once it's loaded.

plexus avatar Oct 06 '17 09:10 plexus

Good points. I've modified load-gist to return to original namespace after eval. (it'll be there on next push)

Some thoughts...

I've been trying to keep the evaluation strategy the same as ClojureScript itself, so that code written in Maria would behave identically (minus some introspection stuff) in any environment which required the same deps as the maria.user namespace.

The main tool we have for building live, async-friendly things for now is cells, which is implemented as a plain library but can do all of this 'waiting around' stuff.

it would be possible to make a version of load-gist that worked inside of a cell, and one could have other cells only load after it is finished. But this would be tedious, and miss the point that the forms in an example like yours have a static dependency which shouldn't require reorganizing all of the code into a dataflow format.

so we have the question, 'how and where do we declare static dependencies'.

In the Clojure world it looks like Alex Miller's tools.deps.alpha / 'Dependency Heaven' stuff is where things are moving. it offers an extensible format where one can easily imagine declaring gist or github dependencies, in a separate deps.clj file which could be saved in the gist alongside the source file, processed by Maria, deps resolved before eval.

Although we could implement a hack quickly/now that would change the eval strategy to wait for certain forms, etc., I think I'd rather first attempt the above path, even it takes more time, and see if we can do all this in an interoperable way.

mhuebert avatar Oct 06 '17 14:10 mhuebert