[erlang-questions] Documentation: type of filename parameter in ets:tab2file/2

Kostis Sagonas kostis@REDACTED
Thu Oct 2 16:21:39 CEST 2008

Paulo Sérgio Almeida wrote:
> I noticed that the documentation of ets:tab2file/2 says:
> tab2file(Tab, Filename) -> ok | {error,Reason}
> Filename = string() | atom()
> Shouldn't it be a name() instead as in the file module:
> name() = string() | atom() | DeepList
>    DeepList = [char() | atom() | DeepList]
> I tried using a deeplist and it works.

In my opinion one should be careful not to repeat historical accidents 
that arguably are signs of bad programming language design.

While I could possibly see some convenience arguments why one would want 
to allow a file name as something constructed out of a list of atoms and 
strings, so that one can e.g. write:

	-define(Application, myapp).   %% Aren't macros great?
	-define(Suffix, ".erl").

then later

	Filename = [?Application, "_", myfile, ?Suffix],

and finally use it in a call to:

	file:open(Filename, [read])

without having to go into the trouble to put a call to lists:concat/1 in 
between, I see very little reason to allow all possible combinations 
that the definition of DeepList above permits so that the following is 
also a valid file name:

	Filename = [this,['_',"is","_",a,"l",so,['_',["a",[],

In an ideal Erlang world, file names are just strings.


More information about the erlang-questions mailing list