[erlang-questions] Variable naming conventions

Jayson Vantuyl <>
Sun Apr 4 23:24:52 CEST 2010


> I also find that having short variable tends to make the code more
> readable.
Ditto here.

> Using indexes on names is a very good way of indicating that this
> references some data which flows through the function and may have
> been updated, for example State0, State1, ..., or as I would probably
> write it: St0, St1, ... . If you use it when the variables are not
> connected then you are asking for trouble.
I do this all the time.  It's really not that bad.  I can't claim that my functions are exhibit ideal style (especially in the grittier systems code), but I find that a numerical sequence has higher information per character than using more words to imbue more specific meaning.

For example, in erlctl I do this a bit when processing the command-line into my options proplist.  Code here:

http://github.com/jvantuyl/erlctl/blob/master/lib/erlctl-0.1/src/erlctl_cmdline.erl#L21

In that function, I can't imagine a better way to name Opts.  I suppose I could have broken it into different functions and traversed them somehow, but I just don't see that as being any clearer.

-- 
Jayson Vantuyl




More information about the erlang-questions mailing list