Ets match on a record vs Dialyzer
Zoltan Lajos Kis
kiszl@REDACTED
Fri Sep 18 20:59:57 CEST 2009
Hello,
I would like to match entries in an ets table based on some fields of
records, as in the example module below.
When using the _='_' form for defining the "don't care" record fields,
Dialyzer emits the following (reasonable) warnings:
rec.erl:6: Function p/0 has no local return
rec.erl:9: Record construction #rec{x::1,y::'_',z::'_'} violates the
declared type for #rec{}
With multiple functions and modules, the no local return causes an an
avalanche of further no local return's and never called's.
Of course I could redefine the field types as {x::integer()|'_',
y::integer()|'_', z::integer()|'_'} but I would prefer another match
syntax or Dialyzer directive if available. So what choices do I have?
Best Regards,
Zoltan.
----------------------
-module(rec).
-export([p/0]).
-record(rec, {x::integer(), y::integer(), z::integer()}).
p() ->
ets:new(table, [named_table, {keypos, #rec.x}]),
ets:insert(table, [#rec{x=1,y=2,z=3}, #rec{x=4,y=5,z=6}]),
ets:match_object(table, #rec{x=1, _='_'}).
More information about the erlang-questions
mailing list