libera/#lisp - IRC Chatlog
Search
17:37:53
rendar
i have: `(store_to_db (get_url a.com) (get_url b.com))` both store_to_db and get_url are async operations, i can execute in the same time. I can't execute store_to_db before executing 2 get_url so i have to wait get_url completion
17:41:50
jackdaniel
before you invoke the function store_to_db you first need to evaluate its arguments
17:42:36
jackdaniel
so first you evaluate (get-url "a.com"), then you evaluate (get-url "b.com") and after that you evaluate (store-to-db <result-1> <result-2>)
17:43:41
rendar
(store_to_db (get_url a.com) (get_url (get_url_name_from my_server)) (get_url b.com))
17:44:28
rendar
with async operations, i can fire HTTP GET for both a.com and b.com, and query my_server all at the same time
17:44:49
rendar
then, when get_url_name_from completes, i can run get_url on that, and then store_to_db
17:45:15
rendar
but the important thing here is to *collect* async operations that can be execute in one shot
17:45:30
jackdaniel
in common lisp arguments are evaluated left to right, in scheme it is not defined (so you may very well evaluate them at the same time)
17:47:21
rendar
yes, but as you can see from my example, i can't use normal recursive evaluation, imho
17:48:51
White_Flame
basically (p1 = get_url a.com).then((p2 = get_url b.com)).then((store_to_db a b))
17:48:57
White_Flame
basically (p1 = get_url a.com).then((p2 = get_url b.com)).then((store_to_db p1 p2))
17:49:51
rendar
White_Flame, here mean that you fire 2 HTTP GET in the same time, then you wait for both websites results