[erlang-questions] noob namespace question

James Aimonetti james@REDACTED
Wed Dec 12 19:24:53 CET 2012


On Wed, 12 Dec 2012 23:44:43 +0530
Rustom Mody <rustompmody@REDACTED> wrote:

> On Wed, Dec 12, 2012 at 11:30 PM, Loïc Hoguin <essen@REDACTED> wrote:
> 
> > On 12/12/2012 06:58 PM, Rustom Mody wrote:
> >
> >> In Erlang variables start with a capital letter, atoms start with a
> >> lowercase letter.
> >> Functions also start with lowercase.
> >>
> >> How does Erlang distinguish atoms and functions? Especially in the
> >> context of higher order functions.?
> >>
> >> [Disclaimer: noob to Erlang but not functional programming or Lisp.
> >> Erlang atoms look quite close to Lisp atoms though also different...]
> >>
> >
> > Function names are atoms.
> >
> > Funs don't have a name (yet) so there's no naming happening there.
> >
> 
> 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?

fun h/1 is the function h of arity 1
foo is an atom
fun foo/2 is the function foo of arity 2

So to pass the function foo to h,

h(fun foo/2).

Does that help?


-- 
James Aimonetti
Distributed Systems Engineer / DJ MC_

2600hz | http://2600hz.com
sip:james@REDACTED
tel: 415.886.7905
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121212/61f5ef0c/attachment.bin>


More information about the erlang-questions mailing list