Small poll

Bengt Kleberg Bengt.Kleberg@REDACTED
Thu Dec 18 10:29:06 CET 2003

Chris Pressey wrote:
> In this style, you write code very aggressively.  You might have a
> function like (this is just an example, not meant to do anything
> useful:)
>   foo(Bar) ->
>     ok = file:setcwd(moo(Bar)),
>     {ok, File} = file:open(zoo(Bar)),
>     {ok, Records} = read_records(File),
>     ok = file:close(File),
>     Records.

in this case i think the compiler will complain about read_records/1 
beeing unknown :-)

seriously, if i have a module which _only_ contains (exported) functions 
that will always fail at runtime i do think the compiler should refuse 
to compile it.
(btw: i think the compiler should refuse to compile a module without any 
exported functions, too)
if some of the (exported) functions might work at runtime, then the 
compiler should compile, but warn about the always failing functions.


> But even if you don't use it, you have to recognize that many
> programmers do, and for the "let it crash" style to work, code has to be
> allowed to crash at runtime, even when it "can't be right".

yes, i am all for letting code crash. i just do not think it is usefull 
to let the compiler produce code for a module that will always crash 
because potentially correct code is written in such a way as to produce 
a runtime error.

if an runtime error is what you want.


More information about the erlang-questions mailing list