Re: functional implementation of core.async primitives

2017-12-13 Thread Timothy Baldridge
Great! So while this works, you'll still have a few problems, namely in places that are not in a tail call position. For example, core.async support this sort of behavior ;; inside an argument list (not a let) (go (println "GOT Value" ( wrote: > I just added `goloop` and `goconsume` to the

Re: functional implementation of core.async primitives

2017-12-12 Thread Divyansh Prakash
I just added `goloop` and `goconsume` to the Clojure implementation, with version of `recur` called `gorecur`. *Example:* > repl> > (def ch (chan)) > #'functional-core-async.core/ch > > repl> > (goconsume [v ch] > (if (= :ok v) > (gorecur) > (println "done"))) >

Re: functional implementation of core.async primitives

2017-12-12 Thread Divyansh Prakash
Just remembered that I did give an example in the README, a port of braveclojure's hotdog machine. (defn hot-dog-machine > [in out hot-dogs-left] > (when (> hot-dogs-left 0) > (go (if (= 3 input) > (go>! [out "hot dog"] > (hot-dog-machine in out (dec

Re: functional implementation of core.async primitives

2017-12-12 Thread Divyansh Prakash
In fact, the JS implementation is much ahead of the Clojure version as of right now - with a better parking algorithm and `goconsume` for creating actors that park on read from a channel in an implicit loop. -- You received this message because you are subscribed to the Google Groups "Clojure"

Re: functional implementation of core.async primitives

2017-12-12 Thread Divyansh Prakash
Hi, @halgari! The JS port actually does have this, just haven't found the time to port it back. But basically we can define something like: (defn goloop* > [f initial-state] > (letfn [(recur+ [state] > (goloop* f state))] > (go > (f recur+ initial-state > > >

Re: functional implementation of core.async primitives

2017-11-22 Thread Timothy Baldridge
I'm not exactly sure how the library works, honestly. It's seems that we still don't have parking take, instead we have callbacks again? I'd love to see an implementation of something like this with your library: (go (println "Count" (loop [acc 0] (if-some [v ( wrote: > Thanks for

Re: functional implementation of core.async primitives

2017-11-22 Thread Divyansh Prakash
Thanks for the encouragement, Jay! I ported the library over to JS, and now we have coroutines in vanilla JavaScript! Porting it to other systems should be fairly straightforward.  - Divyansh -- You received this message because you are subscribed

Re: functional implementation of core.async primitives

2017-11-21 Thread Jay Porcasi
keep it up, it's very interesting to follow Jay On Wednesday, November 22, 2017 at 2:52:46 AM UTC+7, Divyansh Prakash wrote: > > Just a follow up. > I have implemented parking versions of *!*, but (because I'm > not a sorcerer like *@halgari*) they are rather simple and not as > powerful as

Re: functional implementation of core.async primitives

2017-11-21 Thread Divyansh Prakash
Just a follow up. I have implemented parking versions of *!*, but (because I'm not a sorcerer like *@halgari*) they are rather simple and not as powerful as *core.async*'s versions. I now understand what more *core.async* is doing, and where my implementation falls short. I do believe I have a

Re: functional implementation of core.async primitives

2017-11-16 Thread Divyansh Prakash
Actually, returns in ~1700ms if I increase buffer width to 1000 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your

Re: functional implementation of core.async primitives

2017-11-16 Thread Divyansh Prakash
The other example on that thread has stranger charesteristics: (defn bench [] > (time >(let [c (chan 100)] > (go >(dotimes [i 10] ;; doesn't return for 1e5, takes ~170ms for 1e4 > (>! c i)) >(close! c)) > (loop [i nil] >(if-let [x (

Re: functional implementation of core.async primitives

2017-11-16 Thread Divyansh Prakash
Here 's a port of a core.async example that I was able to pull of the mailing list. Performance (in this particular case) seems to be the same. I'm trying out more examples as I find them. -- You received this message because

Re: functional implementation of core.async primitives

2017-11-15 Thread Divyansh Prakash
(which also resolves this blocking go problem ... in a way) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your

Re: functional implementation of core.async primitives

2017-11-15 Thread Divyansh Prakash
Hi! I tried resolving that but pre-emption of the current task turned out to be a really, really tough problem, and I believe that's why we need the core.async macros. Anyhow, I have updated the scheduler to autopromote go blocks into actual JVM threads if they block for more than 10ms - poor

Re: functional implementation of core.async primitives

2017-11-15 Thread Timothy Baldridge
I don't think the go blocks play well with the back-pressure. The code I present here deadlocks the scheduler: https://github.com/divs1210/functional-core-async/issues/1 On Wed, Nov 15, 2017 at 2:17 PM, Jay Porcasi wrote: > interested to hear any feedback on these

Re: functional implementation of core.async primitives

2017-11-15 Thread Jay Porcasi
interested to hear any feedback on these features On Wednesday, November 15, 2017 at 3:52:24 PM UTC+7, Divyansh Prakash wrote: > > Hi! > > Thank you for your feedback! > > I've made the following changes to my implementation : > - bounded channels with backpressure > - proper thread

Re: functional implementation of core.async primitives

2017-11-15 Thread Divyansh Prakash
Hi! Thank you for your feedback! I've made the following changes to my implementation : - bounded channels with backpressure - proper thread synchronization - thread blocks that run on actual threads (unlike go blocks) TODO: - alts! - preserve thread local bindings in `go` blocks (`thread`

Re: functional implementation of core.async primitives

2017-11-12 Thread Timothy Baldridge
If you're looking for feedback, the input I gave on Reddit seems like a good place to start ( https://www.reddit.com/r/Clojure/comments/7c0p3c/functional_implementation_of_coreasync/dpmvjpp/). Like I said, it's not really comparable to core.async at all, since it doesn't properly support thread

Re: functional implementation of core.async primitives

2017-11-12 Thread Jay Porcasi
wow looks so neat! i would be interested as well to know what experienced async users have to say Jay On Friday, November 10, 2017 at 1:32:52 PM UTC+7, Divyansh Prakash wrote: > > > Hi! > > I was messing around with Clojure and somehow ended up implementing a > functional > core.async clone