Formatting style?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Formatting style?

chandru
Do you find this more readable??

trade_with_agent(Agent, #trade_task{mode=Mode, market=Market}, Bid) ->
        BidAgentId = Market:bid_agent_id(Bid),
      {Buyer, Seller} = case Mode of
                                  buy -> {Agent, BidAgentId};
                                  sell -> {BidAgentId, Agent}
                                end,
        Id = make_trade(Buyer, Seller, Market, Bid),
        io:format("Agent ~p ~p in ~p~n", [agent:id(Agent), Mode, Id]),
        agent:send(BidAgentId, {trade, Mode, Id}).

cheers,
Chandru

> -----Original Message-----
> From: Shawn Pearce [mailto:spearce]
> Sent: 3 January 2001 03:30
> To: erlang-questions
> Subject: Formatting style?
>
>
> Hey, I'm just curious, how do the ``expert'' Erlang programmers
> format this code:
>
> trade_with_agent(Agent, #trade_task{mode=buy, market=Market}, Bid) ->
> Seller = Market:bid_agent_id(Bid),
> Id = make_trade(Agent, Seller, Market, Bid),
> io:format("Agent ~p buy in ~p~n", [agent:id(Agent), Id]),
> agent:send(Seller, {trade, buy, Id});
> trade_with_agent(Agent, #trade_task{mode=sell, market=Market}, Bid) ->
> Buyer = Market:bid_agent_id(Bid),
> Id = make_trade(Buyer, Agent, Market, Bid),
> io:format("Agent ~p sell in ~p~n", [agent:id(Agent), Id]),
> agent:send(Buyer, {trade, sell, Id}).
>
> I find it difficult to read that they are the same function, just
> different varients of trade_with_agent/4.
>
> I'm just talking about white space and formatting conventions, however
> comments about the function's arguments are certainly welcome as well.
>
> --
> Shawn.
>
>   ``If this had been a real
>     life, you would have
>     received instructions
>     on where to go and what
>     to do.''
>



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.



Loading...