[erlang-questions] suggestion: shorthand functions
Ulf Wiger
ulf@REDACTED
Fri Jan 11 11:45:23 CET 2013
On 11 Jan 2013, at 10:31, Thomas O'Dowd wrote:
> Ulf,
>
> I'm probably missing something but what's wrong with importing functions
> if you are using them so much? Example.
>
> -import(filename, [join/2]).
This can be done in escripts, but not in file:script() files,
and it only addresses the number of keystrokes.
I realize that historically, few people have written such scripts,
if they even knew the function existed. But now that rebar
supports the notion of rebar.config.script for dynamic configuration,
I have seen them popping up here and there.
But, as I said, the different semantics - return a value or raise
an exception - allow you to eliminate a great deal of code that
checks and unwraps values only to pass them on. That, or you
live with the risk of getting ugly badmatch exceptions.
In order to be a real improvement, these wrapper functions would
need to present more informative exceptions too.
BR,
Ulf W
Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com
More information about the erlang-questions
mailing list