Dialyzer - success typing

Adrian Roe <>
Fri Dec 31 13:36:13 CET 2010


I am just cleaning up code in a large project by checking that dialyzer is happy with it and am getting lots of warnings similar to this:

"scheduler.erl:64: Type specification scheduler_gs:trigger_poll() -> 'ok' | '
not_started' is a subtype of the success typing: scheduler_gs:trigger_poll() ->
any()\n"

where I am wrapping a gen_server (gen_fsm etc) call in a public API such as this one.

-spec stop_poll() -> ok | not_started.
stop_poll() ->
    gen_server:call(?SERVER, stop_poll, infinity).

I sympathise entirely with the warning and it very much fits with Erlang's crash and crash early paradigm, so checking seems like a good idea. I can obviously get rid of the warning by wrapping the call in a case statement

-spec start_poll() -> ok | already_polling.
start_poll() ->
    case gen_server:call(?SERVER, start_poll, infinity) of
                ok ->
                    ok;
                already_polling ->
                    already_polling
    end.

However, this really doesn't improve readability and will get silly if there are lots of possible return values (for example the current state of a gen_fsm).
Am I being stupid?

Happy New Year to one and all.

Adrian


From:  [mailto:] On Behalf Of Attila Rajmund Nohl
Sent: 31 December 2010 12:01
To: erlang-questions
Subject: Re: [erlang-questions] mnesia memory usage on 32 and 64 bits machines


2010/12/31, franz <>:
[...]
> On one hand this makes sense, because as far as I know a word of mem on
> a 32bits machine is 4 bytes, 8 on a 64bits machine. But does this mean
> that having a 64 bits kernel doubles the memory usage?!?

Actually this doesn't depend on the kernel, this depends on the Erlang
VM (i.e. userspace) using 32 bit or 64 bit. Generally 64 bit
applications use a lot more memory.

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:


________________________________

No virus found in this message.
Checked by AVG - www.avg.com<http://www.avg.com>
Version: 10.0.1191 / Virus Database: 1435/3349 - Release Date: 12/30/10


More information about the erlang-questions mailing list