[erlang-questions] how to make beautifulll code of this working code

zxq9 zxq9@REDACTED
Mon Aug 10 21:26:51 CEST 2015


> > Life is too short to waste it reading manual pages - or is it the other way
> > around - life is too short to waste it by not reading manual pages - I
> > can'tmake my mind up

Mostly the second one. Sometimes the first. ...?

> So now I'm wondering how much tinkering's required to reverse engineer
> the docs on the third argument to re:split/3 ;)
> 
> I'm always looking up function docs, for which args come when (they
> tend to be different, wildly) and options. erlang.org/doc/man is a
> very important resource and it'll answer a lot of questions for you.
> 
> Of course the shell is indispensable for playing around with the
> functions - but life is much easier if you have an idea how to use
> them in the first place.

As an additional voice from the peanut gallery...

Erlang has so much stuff in it that you might not expect that I find it to actually be a timesaver to dedicate an entire [however long it takes you] to just skimming the docs to see what is in there. Once.

You probably won't become a master from skimming them once, but you probably will find yourself constantly recalling things like "Hrm... how do I write something that takes an X and returns a Q... oh! There was something like that in the docs..." and saving yourself a lot of time overall.

This becomes a particularly massive mental lever once you get into things larger than individual functions (cases where you wind up reinventing OTP components, which I think everyone does to some degree, at least once) or thinking that OTP is leaving you up a creek because you really need something that can play nicely with OTP pieces but isn't a standard OTP behavior.

That said... I seem to constantly forget the simplest of things... like whether a particular option needs to be [{thingy, value}] or just [value], so knowing how to navigate the docs (which is hardly straightforward) is itself rather valuable.

-Craig



More information about the erlang-questions mailing list