Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Scott Fritchie
committed
Jul 8, 2010
1 parent
f2156b3
commit f44e237
Showing
1 changed file
with
65 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f44e237
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the value of
random:uniform(999999999999)
will never be 666 or 667,regarding the resolution of the
random:uniform/1
function.Are the case statements with the
random:uniform/1
expressions some sort ofplaceholders to write the -spec directives for each NIF?
(I am curious because I've never imagined this sort of
random:uniform/1
usage.)f44e237
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This use of random:uniform() is only to fool the Dialyzer, since it couldn't peek into the C shared library's implementation to get type information. There's almost certainly a better way, but I haven't researched what it is, alas.
f44e237
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's the new-ish erlang:nif_error BIF, but I don't think that would resolve the typing issue.
f44e237
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slfritchie: points taken. I think it won't do much harm even if those case statement choices are executed accidentally since the probability is very very small, and the execution will not happen if the NIF library is successfully loaded.
f44e237
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f44e237
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dizzyd Why didn't you just add
| {error, not_loaded}
to-spec
declarations and simply do not set methods body to{error, not_loader}
? It's perfectly fine with dyalizer.