[erlang-questions] Naming the function

7 views
Skip to first unread message

Avinash Dhumane

unread,
May 17, 2012, 11:30:14 AM5/17/12
to erlang-q...@erlang.org
I am new to Erlang world, and after arriving here I realised that I was in
imperative world of programming.

So, a basic question: how should the name of my function sound?

Should the name sound as if I am declaring a "value" or an "action"? If
latter (i.e. action) then would it not be imperative?

I tend to see "programming a system" as declaring the causal and
structural relations among the values (i.e. forms) in the system; so, I am
beginning to have trouble with naming functions imperatively, yet at the
same time Erlang-library functions are named imperatively.

So, I really need help now.

Thanks
Avinash
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions

Richard O'Keefe

unread,
May 17, 2012, 11:49:31 PM5/17/12
to Avinash Dhumane, erlang-q...@erlang.org

On 18/05/2012, at 3:30 AM, Avinash Dhumane wrote:

> I am new to Erlang world, and after arriving here I realised that I was in imperative world of programming.
>
> So, a basic question: how should the name of my function sound?
>
> Should the name sound as if I am declaring a "value" or an "action"? If latter (i.e. action) then would it not be imperative?

Surely the rules for Erlang are the same as those for any programming
language, as spelled out by Ledgard and Tauer?

- a subprogram which tests whether something is true or false
should be named using an adjective, adjectival phrase,
"is_...", "has_...", and so on
- a subprogram which computes a pure function should be named
using a noun or noun phrase
- a subprogram which is executed for its effects should be
named using an imperative verb phrase

> I tend to see "programming a system" as declaring the causal and structural relations among the values (i.e. forms) in the system; so, I am beginning to have trouble with naming functions imperatively, yet at the same time Erlang-library functions are named imperatively.

I don't believe that anyone has ever argued that _all_ of the Erlang library
is a model of good style (although much of it is), only that it is useful.

There are fairly strict rules about how you ought to name Eiffel subprograms.
There are rules about Java, some of them stinking bad.
There are no official rules about Erlang naming other than "tell the truth
and try not to confuse people".
Reply all
Reply to author
Forward
0 new messages