[erlang-questions] noob namespace question

Robert Virding <>
Thu Dec 13 23:04:48 CET 2012


Yes, Erlang is definitely much closer to Lisp-2 than Lisp-1, especially as you can functions with the same name and different number of arguments (arity) and they are different functions. Don't stretch the analogy too far though. It is NOT that the functions are properties of the name (atom). To uniquely identify a function you need its module name, function name and arity, often written a M:F/A. Erlang doesn't have packages in the CL sense, there is only only one atom space containing all atoms. 

Robert 

----- Original Message -----

> From: "Rustom Mody" <>
> To: "Thomas Allen" <>
> Cc: "Erlang Users' List" <>
> Sent: Wednesday, 12 December, 2012 7:40:26 PM
> Subject: Re: [erlang-questions] noob namespace question

> On Thu, Dec 13, 2012 at 12:00 AM, Thomas Allen < 
> > wrote:

> > On Wed, Dec 12, 2012 at 11:44:43PM +0530, Rustom Mody wrote:
> 
> > > I dont understand. Let me try and be more explicit about my
> > > concern.
> 
> > >
> 
> > > Let h be a higher-order function of one argument (h/1)
> 
> > >
> 
> > > Now in the call h(foo)
> 
> > > How does Erlang know whether foo is a function or an atom?
> 

> > This is not valid, and you will get a "bad function" error if you
> > try
> > to
> 
> > pass your function this way. You must create a "fun" like so:
> 

> > h(fun foo/0)
> 

> > Similarly, you could pass an anonymous fun (like fun(X) -> X end),
> > or
> 
> > a module-function combination (like fun lists:reverse/1).
> 

> Thanks Thomas that answers succinctly.
> In Lisp terminology Erlang is more like a Lisp-2 than a Lisp-1

> http://en.wikipedia.org/wiki/Common_Lisp#The_function_namespace

> --
> http://www.the-magus.in
> http://blog.languager.org

> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121213/a3a67498/attachment.html>


More information about the erlang-questions mailing list