[erlang-patches] Add lists:init/1 - got tired of implementing it

Hans Svensson hanssv@REDACTED
Tue May 21 22:01:01 CEST 2013


> Hello Hans,
> I've got some feedback on your patch after review:
> We have decided to reject this patch as we don't see a general need for
> the new function.
>
> Thanks for showing interest in contributing!
>
> --
>
> BR Fredrik Gustafsson
> Erlang OTP Team
>

That is sad news, and we find it a bit strange since *you* (as in the 
OTP team) yourself seems use this particular function/pattern quite 
frequently. We did a quick search through the OTP code base and found 
quite a few places where this particular function is either implemented 
recursively and used, or just uses reverse(tl(reverse(List)))). Also 
interesting to see is the different names used: first, butlast, but_last 
and remove_last_element.

Code implementing the "init"-function:
compiler
   v3_core:first/1
   v3_kernel:first/1
dialyzer
   dialyzer_contracts:but_last/1
   dialyzer_gui:butlast/1
hipe
   hipe_icode_type:butlast/1
orber
   orber_interceptors:remove_last_element/1

Direct uses of reverse(tl(reverse(L))):
sasl
   in systools_make:smart_guess/3
wx_gen
   in wx_gen:erl_skip_opt2/4
ssh
   in ssh_sftpd

Any further comments on this, it is really not a "new" function it is a 
missing function ;-)

Cheers,

Hans



More information about the erlang-patches mailing list