[erlang-questions] Naming the function

Richard O'Keefe ok@REDACTED
Fri May 18 05:49:31 CEST 2012

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".

More information about the erlang-questions mailing list