[erlang-questions] Process declarations
Vlad Dumitrescu
vladdu55@REDACTED
Thu Oct 5 10:13:29 CEST 2006
Hi,
On 10/5/06, Joe Armstrong <erlang@REDACTED> 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)
mean
Z = spawn(fun()->g(X, Y) end))
while being able to call
Z = g(X, Y)
too.
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
module...
best regards,
Vlad
More information about the erlang-questions
mailing list