[erlang-questions] Package Support/Use

Ulf Wiger (TN/EAB) ulf.wiger@REDACTED
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
normal value.

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

Ulf W

More information about the erlang-questions mailing list