Friday, May 29, 2009

Dialyzer warning: no local return

When you have analyzing erlang beams with a dialyzer and see that warning:

module.erl:51: Function init/1 has no local return

check out all used records in this function for right type definitions of its items. For example, if record defined as

-record(state, {
name :: string(),
data :: binary()
}

and usage of state is

init([]) ->
{ok, #state{name = "Name", data = "Data"}}

this warning will appears.

Wednesday, May 20, 2009

Trivial examples of AMQP usage

Trivial examples of AMQP dispatcher and client in Erlang:
http://github.com/Zert/amqp-erlang-sample/tree/master

make_ref() hint

BIF make_ref() returns built-in type ref() which is unique on this node. Type ref() contains name of node if erl started with -sname or -name parameters, therefore we can use ref() in distributed systems for some unique value through all nodes. BTW, keep in mind that reference will re-occur after approximately 2^82 calls.