Formatting style?

Chandrashekhar Mullaparthi Chandrashekhar.Mullaparthi@REDACTED
Wed Jan 3 10:31:50 CET 2001

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}
	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}).


> -----Original Message-----
> From: Shawn Pearce [mailto:spearce@REDACTED]
> Sent: 3 January 2001 03:30
> To: erlang-questions@REDACTED
> 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.''

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.

More information about the erlang-questions mailing list