[erlang-patches] [PATCH] Fix -spec for file:write_file/3

Kostis Sagonas kostis@REDACTED
Mon Feb 14 13:17:12 CET 2011


Magnus Henoch wrote:
> Change type for second parameter from binary() to iodata(), since the
> function explicitly takes steps to accept lists as well as binaries.

Let me add a comment, more FYI. The intention for specs in files is to 
correspond to the published OTP documentation.

So, actually in this case the change that Magnus suggested needs to 
happen not only for the reason he mentions, but primarily so that it 
corresponds to the published documentation which states iodata() for the 
second argument of this function.

Well spotted Magnus!  Please contribute more such patches when you 
notice some discrepancy between the spec of some function and its 
published documentation.

Kostis

> ---
>  lib/kernel/src/file.erl |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl
> index bc95359..a7a6e96 100644
> --- a/lib/kernel/src/file.erl
> +++ b/lib/kernel/src/file.erl
> @@ -240,7 +240,7 @@ write_file(Name, Bin) ->
>  %% when it is time to change file server protocol again.
>  %% Meanwhile, it is implemented here, slightly less efficient.
>  
> --spec write_file(Name :: name(), Bin :: binary(), Modes :: [mode()]) -> 
> +-spec write_file(Name :: name(), Bin :: iodata(), Modes :: [mode()]) -> 
>  	'ok' | {'error', posix()}.
>  
>  write_file(Name, Bin, ModeList) when is_list(ModeList) ->


More information about the erlang-patches mailing list