[erlang-questions] Dialyzer bug or some problem with my code

ok@REDACTED ok@REDACTED
Tue Mar 22 06:11:58 CET 2011


> Okay, that's unfortunate.  I realize I'm peeking behind the curtain here
> but
> what other choice do I have without any sort of dict:is_dict/1 function.

The fact that you want to ask the question means that you have
some datum X which *might* be a dict or it might be something
else.

Since dict is not a primitive Erlang type, there is *no* "something else"
which will *certainly* not be a possible dict in some future revision.
For example, the dict maintainers might decide to put the data in a
table of some sort and simply pass out some sort of token, an integer
perhaps.

Why isn't there a dict:is_dict/1?  For the converse reason: there is no
possible data structure that the dict module can use that cannot be
forged or accidentally infringed on by an outside data type.

The fact that Erlang has no unforgeable abstract data types is in some
ways regrettable and in some ways useful.  The Dialyzer does much to
reduce the regrettable aspects.

The only way to make the test safely is to put your *own* wrappers
around abstract data types.  *YOUR* code should be responsible for
passing around {dict,X} or {non_dict,Y} terms, wrapping and unwrapping
when necessary.  This the Dialyzer can help you with.



More information about the erlang-questions mailing list