variable naming conventions

Ulf Wiger etxuwig@REDACTED
Thu Nov 9 14:53:35 CET 2000

As I peeked into snmp_misc.erl, the following function caught my eye:

%% Check if a Tag is a member in a TagList.  Tags and TagLists are
is_tag_member(Tag, TagList) ->
    check_tag_list(TagList, [], lists:reverse(Tag)).

check_tag_list([32 | T], Res, Gat) ->
    tag_delimiter_found(Res, Gat, T);
check_tag_list([9 | T], Res, Gat) ->
    tag_delimiter_found(Res, Gat, T);
check_tag_list([13 | T], Res, Gat) ->
    tag_delimiter_found(Res, Gat, T);
check_tag_list([11 | T], Res, Gat) ->
    tag_delimiter_found(Res, Gat, T);
check_tag_list([Char | T], Res, Gat) ->
    check_tag_list(T, [Char | Res], Gat);
check_tag_list([], Res, Gat) ->
    tag_delimiter_found(Res, Gat, []).

tag_delimiter_found(Gat, Gat, T) ->
tag_delimiter_found(_Res, Gat, []) ->
tag_delimiter_found(_Res, Gat, T) ->
    check_tag_list(T, [], Gat).

It took me a while to understand what the heck was the meaning with
the variable "Gat". Finally, I realized that it was "Tag" backwards,
since check_tag_list/3 is called with lists:reverse(Tag).

Way to go! (:
A short comment would have saved me 30 seconds of confusion.
Personally, I would have gone with something like ReversedTag.

Ulf Wiger                                    tfn: +46  8 719 81 95
Senior System Architect                      mob: +46 70 519 81 95
Strategic Product & System Management    ATM Multiservice Networks
Data Backbone & Optical Services Division      Ericsson Telecom AB

More information about the erlang-questions mailing list