[erlang-questions] lists:concat with non-string sublists
James Aimonetti
james@REDACTED
Tue May 22 19:27:32 CEST 2012
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to the docs[1], lists:concat/1 converts the elements in the
list to their string representation. The spec for Thing being atom() |
integer() | float() | string().
However, in the actual implementation in lists.erl, the is_list/1
guard is used in thing_to_list/1, not a more specific check that the
list is a string().
So, according to the docs, I would expect:
> lists:concat([[{foo, 123}], [{bar, 234}]]).
to fail. It doesn't, and returns [{foo, 123}, {bar,234}]. Reading the
implementation of concat/1 its easy to see why this works.
My question is, should the docs be updated to allow Thing to be a list
of any term so Dialyzer won't issue an error when using sub-lists with
tuples (in my case, the result of an ets:match/2), or should
thing_to_list/1 do more inspection of a list element?
Thanks,
James
[1] http://www.erlang.org/doc/man/lists.html#concat-1
- --
James Aimonetti
Distributed Systems Engineer / DJ MC_
2600hz | http://2600hz.com
sip:james@REDACTED
tel: 415.886.7905
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJPu8yEAAoJENc77s1OYoGgk2sH/1T+ZafjSyZXdLLCs0vJcyJe
rK/HAVBoKG+8u/t2PxNul3J6abgEnFsad33BA51xMvFfNnIDBifGKT0HDaXaXXBg
gzCgaKMRQWajMHuGLHxWWhFWXFseg8ZK8WoYOkRewwoC3leTF7C8KfL68cHCLKw7
oMI+46OkjKog1tCuMVmuXXK8LD+z/mKbDhAB7saeLcXwcWJFduTlvmqyvV4wwaIV
v9HKDpy21Em/qyICgwO+WaP4CjDrZmTcwAfimJzI06gJOp31m06EOk3aAIW+q1ja
GP5zXVCkmZ3/C/63yO7b6m6AXQqi56yOww7c20Im3KtRGjjplWUyUwoJpzMJsNc=
=eioK
-----END PGP SIGNATURE-----
More information about the erlang-questions
mailing list