Versioned variable names

Attila Rajmund Nohl attila.r.nohl@REDACTED
Tue Jun 9 17:12:34 CEST 2009


Hello!

I think there wasn't any grumbling this month about the immutable
local variables in Erlang, so here's real world code I've found just
today:

    % Take away underscore and replace with hyphen
    MO1 = re:replace(MO, "_", "-", [{return, list}, global]),
    MO2 = toupper(MO1),
    % Replace zeros
    MO3 = re:replace(MO2, "RX0", "RXO", [{return, list}, global]),
    % Insert hyphen if missing
    MO5 = case re:run(MO3, "-", [{capture, none}]) of
	      nomatch ->
		  insert_hyphen(MO3);
	      match ->
		  MO3
	  end,

I think it's fairly clumsy to use MOx (MO for managed object) in the
code. MO4 was removed during the regexp->re refactoring step. How to
eliminate the versioned variable names? The
MOAfterUnderscoresWereReplaced, UpperCaseMO, MOAfterRX0WasReplaced,
etc. variablenames are really ugly. It used to use regexp, so at that
point it wasn't possible to easily nest the whole into one call, but
that would be still ugly. So any other ideas?


More information about the erlang-questions mailing list