Unused functions.

Bengt Kleberg eleberg@REDACTED
Wed Feb 5 12:42:37 CET 2003


> From: "Pierpaolo BERNARDI" <bernardp@REDACTED>
> To: <erlang-questions@REDACTED>
> Subject: Unused functions.
> Date: Wed, 5 Feb 2003 04:20:40 +0100

...deleted

> I have a bunch of functions that are called only via apply. 
> The compiler warns that these functions are unused and 
> removes them.

there is a suggestion from richardc@REDACTED to not use apply at all.
see his new erlang standard library packages. for those that do not
have them i will quoute from the CONVENTIONS file:

		- Don't use apply(Module, Function, Arguments)
		  unless the Arguments list actually *can* vary
		  arbitrarily in length. (This is rarely the case.)
		  Instead, use:

			Module:Function(Arg1, ... ArgN)

		  Where Module and/or Function is a variable.
		  (This is *much* more efficient than 'apply'.)

		  If Arguments can have one of a limited number of
		  lengths, then write an explicit switch:

			case Arguments of
			    []       -> Module:Function();
			    [A1]     -> Module:Function(A1);
			    [A1, A2] -> Module:Function(A1,A2)
			end

		  (This is still more efficient, and also has the
		  advantage that it catches illegal-length argument
		  lists.)

		  Never use erlang:apply/2. (If you did not know it
		  existed, then just forget about it again.)



bengt




More information about the erlang-questions mailing list