msantos / pkt

Erlang network protocol library
http://blog.listincomprehension.com/search/label/epcap
BSD 3-Clause "New" or "Revised" License
150 stars 44 forks source link

naming of type #27

Closed shun159 closed 9 years ago

shun159 commented 9 years ago

Hi @msantos

https://github.com/msantos/pkt/blob/master/src/pkt.erl#L73

-type nibble() :: 0 .. 16#ff.

I think "0 .. 16#ff." is should uint8_t. And "nibble(unsigned_int 0..16#f)" type name is ambiguous.

Sorry for my broken English

regards.

msantos commented 9 years ago

@shun159 thanks!

And "nibble(unsigned_int 0..16#f)" type name is ambiguous.

Is that a dialyzer error or is the type itself ambiguous? If so, what do you suggest?

Thanks again for catching this!

shun159 commented 9 years ago

If against your will, I'm sorry.

this is not a relevant to dialyzer. this issue is related to the naming of the type. The intent of this issue is, recommented to use other words instead of such a unit like "nibble", "byte" and "short" .

for example:

-type bit() :: 0 .. 1.
-type in_port_t() :: 0 .. 16#ffff.
% -type nibble() :: 0 .. 2#1111. added pkt:bit4() instead of pkt:nibble()
-type bit4() :: 0..2#1111.
% added pkt:uint8_t instead of byte()
-type uint8_t() :: 0..16#ff.
-type uint16_t() :: 0 .. 16#ffff.
-type uint32_t() :: 0 .. 16#ffffffff.
-type in_addr() :: {uint8_t() ,uint8_t() ,uint8_t() ,uint8_t() }. % use uint8_t() instead of byte().
-type in6_addr() :: {uint16_t(),uint16_t(),uint16_t(),uint16_t(),uint16_t(),uint16_t(),uint16_t(),uint16_t()}.

sorry for my poor English. Regards.

msantos commented 9 years ago

Much cleaner! Thanks for the feedback!

shun159 commented 9 years ago

:+1: