[erlang-questions] Package Support/Use
Ulf Wiger (TN/EAB)
Mon Nov 6 11:37:48 CET 2006
Richard A. O'Keefe wrote:
> In other languages, for example, coming to the end of a file
> is NOT exceptional; most "files" HAVE an end. So a language
> shouldn't indicate reaching the end of a file (for the first
> time, at least) by raising an exception.
I agree that a library function, "read the next N bytes of data", can
return eof as a normal value. One could argue that a function "starting
at position P, read N bytes of data", should not.
It all boils down to whether an outcome is expected or not. In a large
number of cases, there is a limited set of return types that are useful,
and I think one should never, as a rule, return a useless result as a
To continue with the file library, why, for example, does file:read/2
not crash when fed garbage?
3> file:read(bugger, 32).
4> file:read(bugger, a).
More information about the erlang-questions