|
|
| Author |
Message |
|
| Guest |
Posted: Thu Sep 29, 2011 6:25 pm |
|
|
|
Guest
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
We use -Wunderspecs a lot in our Dialyzing and the only minor complaint
I have is when I get warnings that the success typing is more specfic
with the binary() type.
We see a lot of:
foo.erl:123: Type specfication foo:a_fun(BinVal) -> 'ok' when
is_subtype(BinVal, binary()) is a supertype of the success typing:
foo:a_fun(<<_:8,_:_*8>>) -> 'ok'.
In foo.erl, a_fun/1 is defined as:
- -spec a_fun(BinVal) -> 'ok' when
BinVal :: binary().
a_fun(BinVal) ->
%% do something with BinVal
ok.
This is obviously a simplified, trivial example. Just curious if its
possible to have Dialyzer *not* output the -Wunderspecs warnings for
binaries? Or if there's a better way to specify binary inputs/outputs
(since not all of our functions using binary() in the spec have this issue).
This is in R14B03, if that makes a difference.
Thanks,
James
- --
James Aimonetti
Distributed Systems Engineer / DJ MC_
2600hz | http://2600hz.com
sip:james@2600hz.com
tel: 415.886.7905
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJOhLh2AAoJENc77s1OYoGg9m8H/iiILocPGlrCEwpg1xdVsQEO
E6AZbrvjJHSpieJUfCLmuSUH7K3qQxdDPNA1l2S9QIzCm+TmeBSj37GVdW5gj5i3
SGTQoCYEgUmDqJISK7QgmGePms+3PmpN1HDw18Y1QwddXcbznSl05bCgGOhyFKee
At7zjLDbuhONzU8gB8aoCdzetSzUxbs0CzNggi7y1qdzLY7POuCVOa6+g8Oo7HY/
kd0490D7By68vlp2ALGcW1fSVZk8Zb5MFd+dA3TFgyXzfEPtKx6xvX/lTzi2COdc
5T3hk1jxCeUkTsvLcUq2ZtrjXzwWhPrDjPoThPMWr3DiO++y6j8TCwV3F/e1tJA=
=kdk0
-----END PGP SIGNATURE-----
_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
Post received from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Fri Sep 30, 2011 6:42 am |
|
|
|
Guest
|
On 09/29/11 21:27, James Aimonetti wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> We use -Wunderspecs a lot in our Dialyzing and the only minor complaint
> I have is when I get warnings that the success typing is more specfic
> with the binary() type.
>
> We see a lot of:
>
> foo.erl:123: Type specfication foo:a_fun(BinVal) -> 'ok' when
> is_subtype(BinVal, binary()) is a supertype of the success typing:
> foo:a_fun(<<_:8,_:_*8>>) -> 'ok'.
>
> In foo.erl, a_fun/1 is defined as:
>
> - -spec a_fun(BinVal) -> 'ok' when
> BinVal :: binary().
> a_fun(BinVal) ->
> %% do something with BinVal
> ok.
>
> This is obviously a simplified, trivial example.
It's not just a simplified example. It's an example that is incomplete
because it does not show the problem. Here is one that does:
-module(foo).
-export([a_fun/1]).
-spec a_fun(binary()) -> 'ok'.
a_fun(B) ->
do(B), ok.
do(<<_>>) -> ok;
do(<<_,R/binary>>) -> do(R).
Note that the first clause of do/1 has a non-empty binary there (there
is an underscore). From this clause dialyzer will infer that the do/1
function only returns if its argument is a non-empty binary of at least
one byte.
> Just curious if its
> possible to have Dialyzer *not* output the -Wunderspecs warnings for
> binaries?
Why on earth would we want to special case this?
> Or if there's a better way to specify binary inputs/outputs
> (since not all of our functions using binary() in the spec have this issue).
As I explained, the warning is related to the fact that these functions
only accept non-empty binaries. (Whether this is intentional or not in
your code I will let you decide.) To suppress these warnings I
recommend the following: define a non-empty binary type
-type ne_binary() :: <<_:8,_:_*8>>.
and change the spec of your a_fun above to:
-spec a_fun(ne_binary()) -> 'ok'.
(Aside: I do not see the need to use 'when' for type variables that only
appear once in a spec. The non when form is shorter and nicer.)
Kostis
_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
Post received from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Sat Oct 01, 2011 5:00 pm |
|
|
|
Guest
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Thanks for the clarification Kostis. Always nice to deepen my
understanding of how to use Dialyzer more effectively.
James
On 09/29/2011 11:41 PM, Kostis Sagonas wrote:
> On 09/29/11 21:27, James Aimonetti wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> We use -Wunderspecs a lot in our Dialyzing and the only minor complaint
>> I have is when I get warnings that the success typing is more specfic
>> with the binary() type.
>>
>> We see a lot of:
>>
>> foo.erl:123: Type specfication foo:a_fun(BinVal) -> 'ok' when
>> is_subtype(BinVal, binary()) is a supertype of the success typing:
>> foo:a_fun(<<_:8,_:_*8>>) -> 'ok'.
>>
>> In foo.erl, a_fun/1 is defined as:
>>
>> - -spec a_fun(BinVal) -> 'ok' when
>> BinVal :: binary().
>> a_fun(BinVal) ->
>> %% do something with BinVal
>> ok.
>>
>> This is obviously a simplified, trivial example.
>
> It's not just a simplified example. It's an example that is incomplete
> because it does not show the problem. Here is one that does:
>
> -module(foo).
> -export([a_fun/1]).
>
> -spec a_fun(binary()) -> 'ok'.
> a_fun(B) ->
> do(B), ok.
>
> do(<<_>>) -> ok;
> do(<<_,R/binary>>) -> do(R).
>
> Note that the first clause of do/1 has a non-empty binary there (there
> is an underscore). From this clause dialyzer will infer that the do/1
> function only returns if its argument is a non-empty binary of at least
> one byte.
>
>> Just curious if its
>> possible to have Dialyzer *not* output the -Wunderspecs warnings for
>> binaries?
>
> Why on earth would we want to special case this?
>
>> Or if there's a better way to specify binary inputs/outputs
>> (since not all of our functions using binary() in the spec have this
>> issue).
>
> As I explained, the warning is related to the fact that these functions
> only accept non-empty binaries. (Whether this is intentional or not in
> your code I will let you decide.) To suppress these warnings I
> recommend the following: define a non-empty binary type
>
> -type ne_binary() :: <<_:8,_:_*8>>.
>
> and change the spec of your a_fun above to:
>
> -spec a_fun(ne_binary()) -> 'ok'.
>
> (Aside: I do not see the need to use 'when' for type variables that only
> appear once in a spec. The non when form is shorter and nicer.)
>
> Kostis
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@erlang.org
> http://erlang.org/mailman/listinfo/erlang-questions
>
- --
James Aimonetti
Distributed Systems Engineer / DJ MC_
2600hz | http://2600hz.com
sip:james@2600hz.com
tel: 415.886.7905
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJOh0c7AAoJENc77s1OYoGgrUcH/26BfA8xBLQ95H4541KazZ7M
i5mHR4qFItD0+L1P6x/SfoOr0KFkAhoggyawUmh6pHki7l8Jq1Y5VvRDSOrJR2uU
4Ob18pENuQonvgwv7jxZLKANl67Q58oglAfJVh6FGq+4C5ksIXsqKtNl5PGOSyCE
E1AAGkMzmsJqGEBSBiujPM0IZF/9JCSfLI6FRu/LP2gAY8pijJRaJLYX0Ubv3sbU
0cRB+UIR4pteWiytAdsGoSlaOpmm4yrBNfIyBFMqaR7B+ki3fv+VP5RmiFcqb16q
ujVWz0xID/iU92nZm3nT+DGmPzUkTiNaZ11N6p76yzLc9mtka4JNfunfIicw/Js=
=jXxw
-----END PGP SIGNATURE-----
_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
Post received from mailinglist |
|
|
| Back to top |
|
| wuji |
Posted: Wed Aug 22, 2012 8:14 am |
|
|
|
User
Joined: 10 Aug 2012
Posts: 654
|
a link to go to Netflix, you would wind up up jordan 6 up at "BudgetMatch," according to the FBI. The practice is
"click hijacking."Once the FBI got around to fixing the problem problem [h4]cheap jordans[/h4] problem in 2011, it realized it couldn't simply shut down
rogue servers because infected computers would be left without a a cheap replica *beep* a functioning DNS, leaving them virtually Internet-less. So it set
temporary servers to give malware-infected Internet users time to fix fix jordan 6 fix their computers.And time runs out on Monday, July 9.(There
a planned attack this Monday that will shut down the the imitation designer *beep* the Internet; those whose computers are already infected will lose |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|