[erlang-questions] Dialyzer question
Kostis Sagonas
kostis@REDACTED
Fri Dec 23 08:16:40 CET 2011
On 12/23/11 08:30, Zabrane Mickael wrote:
> Hi Kostis, hi guys,
>
> I'd like to express the following intention in my specification:
>
> -spec foo() -> [byte(), byte(), byte()]
> foo() ->
> ...
> return [26, 55, 127].
> ...
> return [0, 13, 255].
>
> *foo/0 must returns a list of exactly 3 bytes().*
>
> Dialyzer complains about that. My actual solution isn't accurate:
> -spec foo() -> [byte()]
> foo() ->
> ...
> return [26, 55, 127].
> ...
> return [0, 13, 255].
>
> Any hint please?
As you note, the type language currently cannot accurately express what
you want.
But, out of curiosity, why do you want to use lists instead of tuples
for something like that? I doubt there is a good reason for this...
Kostis
More information about the erlang-questions
mailing list