[erlang-questions] How to code against an interface rather than an implementation?

Chris Cook cookchrisd@REDACTED
Fri Aug 9 14:40:37 CEST 2013


Afternoon Daniil,

I'm not sure what your getting at, the module that the atom that
State#state.db refers to must export the calling function. Take a look at
this link [0] (Only the atomic names bit the second bit has been removed
from erlang) for more information about the basics of what is going on. The
State is a variable and evaluated like one that's why it is in ().

maybe an easier way of coding it would be.
-record(state, {db=mneisa_module});

M = State#state.db
M:get_content(Tbl, Id)

-module(mneisa_module)
-export([get_content/2]).

-spec(...)
get_content(Tbl, Id) -> ....

[0]
http://userprimary.net/posts/2009/03/04/two-erlang-finds-atomic-names-and-parameterized-modules/

Regards

Chris


On 9 August 2013 12:56, Daniil Churikov <ddosia@REDACTED> wrote:

> Does anybody know could *dialyzer* break through such dynamic module
> construction, like *Chris Cook* wrote? Is it able to know that *
> State#state.db* module do not export *get_content/2* function, or it's
> contract is wrong?
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130809/c3244078/attachment.htm>


More information about the erlang-questions mailing list