[erlang-patches] Add lists:init/1 - got tired of implementing it
Hans Svensson
hanssv@REDACTED
Thu Jan 23 10:50:56 CET 2014
And a few usages of this function introduced as well. Note, HiPE uses
its own utiity function hipe_bb:butlast/1 which could/should be replaced
by droplast as well. But that change looked a bit too invasive so I left
it as an exercise ;-)
I made this branch on top of the branch with lists:droplast/1, I hope I
got it right!
git fetch git://github.com/hanssv/otp.git using_lists_droplast
https://github.com/hanssv/otp/compare/add_droplast_to_lists...using_lists_droplast
https://github.com/hanssv/otp/compare/add_droplast_to_lists...using_lists_droplast.patch
Cheers,
/Hans
On 2014-01-22 23:14, Hans Svensson wrote:
> Finally got around to do the fixes. Screwed up my git branch, so the
> lists:droplast/1 is now in a differently named branch:
>
> git fetch git://github.com/hanssv/otp.git add_droplast_to_lists
>
> https://github.com/hanssv/otp/compare/erlang:maint...add_droplast_to_lists
>
> https://github.com/hanssv/otp/compare/erlang:maint...add_droplast_to_lists.patch
>
>
> A separate patch with usage will follow as soon as I can find the time
> for it!
>
> Cheers,
>
> Hans
>
> On 2014-01-16 11:26, Siri Hansen wrote:
>> Hi Hans!
>>
>> After many and long discussions we have now decided to re-open this
>> patch and approve it with some comments:
>>
>> 1. we would like the name of the function to be 'droplast'.
>> 2. we want the simple recursive implementation with no special handling
>> of bad arguments, i.e. we think it is ok with a function_clause error
>> for arguments that are not non-empty proper lists.
>>
>> Would you mind doing these adjustments in the patch?
>>
>> Best Regards
>> /siri
>>
>>
>> 2013/5/21 Hans Svensson <hanssv@REDACTED <mailto:hanssv@REDACTED>>
>>
>> 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
>>
>> _________________________________________________
>> erlang-patches mailing list
>> erlang-patches@REDACTED <mailto:erlang-patches@REDACTED>
>> http://erlang.org/mailman/__listinfo/erlang-patches
>> <http://erlang.org/mailman/listinfo/erlang-patches>
>>
>>
>
More information about the erlang-patches
mailing list