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" (<! c)))
;; in a do
(go
(do (println "Before")
(<! c)
(println "After")))
;; Before a branch
(go
(if (<! c)
(println "true")
(println "false")))
In essence what you have is a bit of syntactic sugar over callbacks. It's
still "callback hell" in the sense that you have to always be in a tail
recursive position, and have to manually transform your code into
continuation passing style.
Timothy
On Tue, Dec 12, 2017 at 7:15 PM, Divyansh Prakash <
[email protected]> wrote:
> 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")))
>> #object[java.util.concurrent.ArrayBlockingQueue 0x30bb0ac9 "[[]]"]
>>
>> repl>
>> (>!! ch :ok)
>> nil
>>
>> repl>
>> (>!! ch :ok)
>> nil
>>
>> repl>
>> (>!! ch :ok)
>> nil
>>
>> repl>
>> (>!! ch :nope)
>> done
>> nil
>>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.