[erlang-questions] Process declarations

Vlad Dumitrescu <>
Thu Oct 5 10:13:29 CEST 2006


On 10/5/06, Joe Armstrong <> wrote:
> Process declarations:
> Proposal 1 (Radical)
> ==========
> Do away with spawn. Replace with a process keyword:

If I understand correctly, you mean that calls to functions declared
as 'process'
  Z = g(X, Y)
will become in fact syntactic sugar for
  Z = spawn(fun()->g(X, Y) end))

I also suppose you meant a similar thing for the second proposal
(because as stated, it only changes having to 'export' a function to
having to 'process' it, which doesn't amount to much.

I'll have to think more about it, but the first reaction is that this
loses some flexibility. I might like to be able to call g(X, Y) both
as a regular function and as a process starter. Don't know if this is
meaningful in practice.

A third option (almost as radical as the first) but where this
flexibility is kept, is to move the 'process' directive to the place
of the call. In other words, we could make 'spawn' a kekyword and have
  Z = spawn g(X, Y)
  Z = spawn(fun()->g(X, Y) end))
while being able to call
  Z = g(X, Y)

Actually, it's not even necessary to make spawn a keyword. We could
have something that in practice amounts to a macro call
  Z = new_spawn(g(X, Y))
where we can't use 'spawn' because we'd shadow the case where g(X,Y)
returns a fun that is to be spawned and I can't come up with a better
suggestion for a name. A parse transform to do that is easy to write -
the crux would be that we shouldn't have to declare it in every

best regards,

More information about the erlang-questions mailing list