receive statement in Erlang

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

receive statement in Erlang

Sean Hinde-2
Vance:

> And I can't skip the opportunity to complain about tabs vs. spaces. :)
> You mix them here which I find makes things hard to read.  Especially
> when you aren't consistent!  I know this is my particular rant but let
> me leave you with this:
>
>     receive
>         Screenpid ->
>     link(Screenpid)
>         end,
>
> Should be:
>
> receive
> Screenpid ->
> link(Screenpid)
> end,

I really don't think it is possible to nicely format Erlang code without
using spaces. What about:

function_with_lots_of_parameters(Param1, Param2, Parameter_with_long_name,
                                           Another_long_parameter,
Final_parameter) ->

And many other times where a bunch of things go across multiple lines but
need to be indented up to their buddies.

Emacs deals with this by tabbing until nearly there and then adding spaces
(all with a single press of the TAB key). It might be even better to set it
up to use just spaces for consistency with other editors but I just use
Emacs..

Regards,
Sean



NOTICE AND DISCLAIMER:
This email (including attachments) is confidential.  If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents.  We cannot accept liability for any breaches of
confidence arising through use of email.  Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions.  We will not accept responsibility for any commitments
made by our employees outside the scope of our business.  We do not warrant
the accuracy or completeness of such information.




Reply | Threaded
Open this post in threaded view
|

receive statement in Erlang

Vance Shipley-2

Sean Hinde writes:
>
> I really don't think it is possible to nicely format Erlang code without
> using spaces. What about:
>
> function_with_lots_of_parameters(Param1, Param2, Parameter_with_long_name,
>   Another_long_parameter,
> Final_parameter) ->


I use the rule that if it's being continued it's one stop more than if
it were the next line:

function_with_lots_of_parameters(Param1, Param2, Parameter_with_long_name,
                Another_long_parameter, And_yet_another, And_another,
                And_another_long_parameter, And_yet_another, And_another,
                And_one_more) ->
        foo(Param1),
        foo(Param2),


That works for me.  It's simply beautiful to see when all your code
changes to fit with one command (changing the tabstops in the editor).
If the code is simple leave the tabs at 8.  If it get's to long and
indented many times than change to tabs=5 or even 1 if neccesary.

Now before someone else says it; yes it's probably time for another
function by then but I'd say sometime after tabs=5 anyway.  (I use 3).

        -Vance