Re:Erlang and code style
by mamcx on Tuesday May 20, 2014 @10:40PM
(#7776433)
I have imagine (for my toy language) that is weird to force one way or another (always handle or always check), but instead use the unix idea of STDOUT/STDERR.
A function return values in STDOUT, and exceptions always go to STDERR:
This is GO style:
file | maybeError? := open('thisnotexist.ever')
And is totally ok to say, python style:
file := open('thisnotexist.ever')
and upper in the chain is possible to catch it:
match MyAwesomeFunction():
StdIn:
StdErr:
Or maybe
try/catch.
The idea is that if stderr is consumed is handled right there, but if not it "throw" and work like a exception.
A function return values in STDOUT, and exceptions always go to STDERR:
This is GO style:
file | maybeError? := open('thisnotexist.ever')
And is totally ok to say, python style:
file := open('thisnotexist.ever')
and upper in the chain is possible to catch it:
match MyAwesomeFunction(): StdIn: StdErr:
Or maybe
try/catch.
The idea is that if stderr is consumed is handled right there, but if not it "throw" and work like a exception.