[erlang-questions] Dialyzer question

Zabrane Mickael zabrane3@REDACTED
Fri Dec 23 08:20:58 CET 2011


On Dec 23, 2011, at 8:16 AM, Kostis Sagonas wrote:

> 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.

OK.

> 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...

You're right Kostis. I'll change the interface to tuple instead of list.
Thanks again ...

Regards,
Zabrane

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111223/cd2c8e26/attachment.htm>


More information about the erlang-questions mailing list