This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-11
Channels
- # architecture (11)
- # bangalore-clj (1)
- # beginners (42)
- # boot (28)
- # chestnut (1)
- # cider (1)
- # cljs-dev (28)
- # cljsrn (7)
- # clojure (124)
- # clojure-austin (1)
- # clojure-italy (10)
- # clojure-russia (3)
- # clojure-spec (29)
- # clojure-uk (32)
- # clojurescript (62)
- # core-async (22)
- # data-science (7)
- # datascript (5)
- # datomic (8)
- # events (1)
- # fulcro (15)
- # funcool (1)
- # jobs (1)
- # keechma (10)
- # lein-figwheel (4)
- # lumo (4)
- # mental-health (1)
- # off-topic (21)
- # om (10)
- # onyx (8)
- # parinfer (29)
- # pedestal (1)
- # planck (4)
- # portkey (2)
- # protorepl (1)
- # random (1)
- # re-frame (12)
- # ring (3)
- # spacemacs (6)
- # uncomplicate (63)
@sophiago have you seen the tests for core.async? They use the pluggable nature of the library to do tests on the macro without running async code. It's a good place to start if you want to hack on the macro a bit
Ooo, thanks. I'm going to take a look now. I'm working on an automatic differentiation library so need to do a lot of source transformation and so far only overrode defn
to dump the ast into metadata, but then I was watching Aysylu Greenberg's talk on Loom from Conj I think three years ago and ended up rewatching (I think?) yours about analyzer and SSA in core.async. It seems it should do a lot of the work for me. Although I guess you never got to the point of writing a general SSA library since Clojure-in-Clojure never really happened?
The gist:
1) create a function with a signature you expect to use in the code pause
in this case
2) create a terminator by adding extra parameters of state
and block
before the normal parameters. pause-run
in this case
3) Wire it all up by copy/pasting the code you see in that test (`runner`) and replacing the terminator hash map with whatever functions you want to be replaced with termiantors
Oh, that's great. I had so far just commented out the terminator lines from parse-to-state-machine
and wasn't sure what to do with the whole thing 😛
So now whenever pause
is called, the code will instead call pause-run
and expect you to tell it when to continue. If you need async functions you can look at these definitions to get some hints: https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/ioc_macros.clj#L1007-L1011
So essentially by playing with this test macro I can get a sense of control flow and eventually start transforming it?
yep, that's a great place to start
I see. A lot of the hard problems in this sort of stuff are considered things like dealing with complex recursion and things you've seemingly already solved.
inside the terminators state
is an array of all the locals and state of the state machine. And block
is a pointer to the next block to jump into once you want to continue running the machine.
I'm going to have to play with it to understand how it works I think. Mainly I'm excited that it handles unrolling local control flow into a state machine because then I should be able to do whatever I want with it, not necessarily anything asynchronous.
I did have an idea to convert local control flow to using agents in order to maximize JVM thread pools, but that was sort of a whim.
Do you have any research you can point me to that helped when writing all this? I've been looking a lot into papers on analyzing control flow. For example I have this one open right now: https://pdfs.semanticscholar.org/853b/b1490af8f2d58c560bf9c4b32de880538d08.pdf