Proposed change to libraries

Richard A. O'Keefe ok@REDACTED
Mon Feb 7 00:26:16 CET 2005


Kostis Sagonas <kostis@REDACTED> wrote:
	For example, one can issue the call:
	
	  lists:map(gazonk, [])
	
	which will return [].
	
Anyone who relies on that deserves the trouble they will one day get.
I"d taken it that the documentation was telling you what you could
*rely* on while the code was subject to change without notice.

	I.e., change the implementation of map/2 (and similar functions)
	as if defined by:
	
	map(F, [H|T]) ->
	  [F(H)|map(F, T)];
	map(F, []) when is_function(F) ->	%% andalso is_fun_arity(F) == 1
	  [].
	
Changing the code to that should permit more effective use of optional
type checking (whatever happened to that, anyway?).  It should also catch
more unintentional errors at run time, which is surely a good thing.
	
Scheme insists on the list argument of map being a proper list, and it
seems to cause no trouble there.



More information about the erlang-questions mailing list