[erlang-questions] Why do we need modules at all?

Josh Johnston josh@REDACTED
Tue May 24 10:49:00 CEST 2011


On 24/05/2011, at 6:39 PM, Dmitrii Dimandt wrote:

>> 
>> So I imagine:
>> 
>>    1) all functions have unique names
>>    2) there are no modules
>>    3) we discover the name of a function by searching metadata
>>       describing the function in a database
>>    4) all public functions (think open source) are in the same
>>       database
>> 
>> We could make a system to do this.
> 
> Hm... you'd still need *some* kind of modules.
> 
> For instance, in Webmachine each resource is expected to have some, or all, of predefined public/exported functions: to_html, resource_exists, allowed_methods etc.
> 
> So, each resource will have functions with the same name. If we move all functions to a global namespace, then how do we differentiate between these functions? Probably by naming them resource_name_function_name?
> 

In a normal language this would be a problem, but in erlang we can get the desired behaviour by using pattern matching, right?

So instead of

to_html()
resource_exists()
etc

We have

	resource(to_html, ...)
	resource(exists, ...)
	etc

I'm not disagreeing with you - we do need some good way to do this. But I don't think modules are necessary in this case.

Josh. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110524/249d9292/attachment.htm>


More information about the erlang-questions mailing list