tags:

views:

96

answers:

1

I've seen module_name:new used in Erlang code, but there is no reference to a "new" function in the module_name module. What does "new" do?

+6  A: 

It is for "parametrized module": see here and there for more details.

jldupont
Whoa!!! So is this basically saying that Erlang has classes after all?
Zubair
Not quite like usual OOP you'll find though...
jldupont
But they also say that this is not a standard part of Erlang? So maybe it will be removed?
Zubair
This is nothing like classes. A parametrized module simply enables you to pass some parameters (common to most of the functions in the module) to functions without including them as arguments.Removing it involves more work than leaving it as it is; so my guess it will be not removed. If it is broken because of some other changes, it might not be fixed...
Zed
Ok, so basically we shouldn't use them? It is just that I've seen them used extensively in many Erlang Open Source projects...
Zubair
@Zubair: I guess it is a risk you need to manage...
jldupont
Well its quite hard to manage, as I need to decide if I allow users to use them in a client API. Anyway, I've added another StackOverflow question regarding this, as if it gets removed then many Erlang products will break
Zubair