[erlang-questions] suggestion: shorthand functions

Thomas O'Dowd tpodowd@REDACTED
Fri Jan 11 10:31:09 CET 2013


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

Tom.

On Fri, 2013-01-11 at 10:12 +0100, Ulf Wiger wrote:
> Since I've been writing a bunch of rebar.config.script code lately,
> I've suffered the agony of trying to write concise and readable 
> code without having to do tons of copy-paste, weird unwrapping
> funs etc.
> 
> What I think would make this sort of thing easier, and also 
> escript programming in general, is if OTP could provide some
> modules with concise naming and let-it-fail semantics.
> 
> Just off the top of my head, I scribbled down a few functions that
> I think would make *my* life easier. I pushed them to github to
> get some discussion going.
> 
> http://github.com/uwiger/shorthand
> 
> The modules are:
> 
> f.erl - shorthand functions for file.erl
> fn.erl - ditto for filename.erl
> e.erl - ditto for erl_eval.erl
> 
> The least beneficial is perhaps filename:erl, but my fingers and
> eyes ache from all the filename:join(filename:dirname(F), …)
> code.
> 
> Otherwise, I think the biggest benefit is to stick to let-it-crash
> programming, which I find is usually the default when I write
> scripts. The original functions are always available if you want
> to take a closer look at return values.
> 
> (For the file:script() counterparts, I also always pass the name
> of the script as a binding).
> 
> Comments?
> 
> BR,
> Ulf W
> 
> Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
> http://feuerlabs.com
> 
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-- 
Cloudian KK - http://cloudian.jp/
S3 REST API Compliant Cloud Storage with Cloudian®




More information about the erlang-questions mailing list