[erlang-questions] Controversial subject of the day: tabs and spaces for indentation

Anthony Ramine n.oxyde@REDACTED
Mon Feb 10 23:19:57 CET 2014


Erlang/OTP already chose indentation and alignment:

move_case_into_arg(#c_case{arg=#c_case{arg=OuterArg,
                                       clauses=[OuterCa0,OuterCb]}=Outer,
                           clauses=InnerClauses}=Inner0, Sub) ->
    case is_failing_clause(OuterCb) of
        true ->
            #c_clause{pats=OuterPats0,guard=OuterGuard0,
                      body=InnerArg0} = OuterCa0,
            %%
            %% case case <OuterArg> of
            %%          <OuterPats> when <OuterGuard> -> <InnerArg>
            %%          <OuterCb>
            %%          ...
            %%      end of
            %%     <InnerClauses>
            %% end
            %%
            %%       ==>
            %%
            %% case <OuterArg> of
            %%     <OuterPats> when <OuterGuard> ->
            %%         case <InnerArg> of <InnerClauses> end
            %%     <OuterCb>
            %% end
            %%
            ScopeSub0 = sub_subst_scope(Sub#sub{t=[]}),
            {OuterPats,ScopeSub} = pattern_list(OuterPats0, ScopeSub0),
            OuterGuard = guard(OuterGuard0, ScopeSub),
            InnerArg = body(InnerArg0, ScopeSub),
            Inner = Inner0#c_case{arg=InnerArg,clauses=InnerClauses},
            OuterCa = OuterCa0#c_clause{pats=OuterPats,guard=OuterGuard,
                                        body=Inner},
            Outer#c_case{arg=OuterArg,
                         clauses=[OuterCa,OuterCb]};
        false ->
            impossible
    end;

Following your TIA theorem, tabs need to go.

-- 
Anthony Ramine

Le 10 févr. 2014 à 23:12, Loïc Hoguin <essen@REDACTED> a écrit :

> On 02/10/2014 11:01 PM, Richard A. O'Keefe wrote:
>>> - Mixed tabs and spaces present challenges for programmer using
>>> different editors and contributing to projects with varied or poorly
>>> defined white space standards
>> 
>> This is somewhat misleadingly phrased.
>> Tabs do this all by themselves.
>> 
>> For example, I once spent some time using a programming
>> language where the IDE on Macs insisted that tabs were
>> equivalent to 4 spaces and the Unix command line tools
>> insisted that tabs were and could only be equivalent to
>> 8 spaces, AND the language was indentation-sensitive.
>> 
>> So remember, it's not "mixed tabs and spaces present
>> challenges", it's "tabs present challenges".
> 
> Tabs are perfectly fine for indentation. You had issues only because you were doing both indentation *and* alignment. If you don't align your code, it doesn't matter what the tab length is.
> 
> Just like the CAP theorem, I posit the TIA theorem: tabs, indentation, alignment, choose two.
> 
> -- 
> Loïc Hoguin
> http://ninenines.eu
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list