Hi,

I'm writing this proposal based on what I've been doing with
Python/Javascript. A way ppl on those communities are doing asynchronous
call nowadays is by declaring an async function and if there is a need to
wait for its result calls the function await. Once we have the module Task
that is capable of handling mostly user cases about async/await feature on
those languages. I think we can add async to the function definition to
implement

defmodule Foo do
  async def bar(x)    # code
  endend



And on the code by calling Foo.bar/1 we return a Task. And by calling
Task.async Foo.foo(1) the result can be returned.

the main benefits on having an approach like that is basically code
readability when it is necessary to run a single function as a separate
process. today that can be done with something like that

task = Task.async(fn ->
  Foo.bar(:arg)end)Task.await(task)


or

task = Task.async(Foo, :bar, [:arg])Task.await(task)


Also another benefit is having a syntax more similar to other languages.
This can make Elixir more welcoming for people from other communities such
as python or javascript.
-- 
Pedro Medeiros
----------------------------------
Cel: +55 (21) 9914-86898
Email: pedro...@gmail.com

Beautiful is better than ugly,
Explicit is better than implicit,
Simple is better than complex,
Complex is better than complicated.

The Zen of Python, by Tim Peters

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAJbPmJM_TAtuV5b39ZaC1gd8njtHCyk3xe2_%2BfdgfwhOcA-L7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to