Hi all,<br>When sending message by <b>Pid ! Message</b>, is it better to use <b>tuple </b>or <b>list </b>or it just does <b>not </b>matter ?<br><br>For example (the area_server0 example in "programming erlang"), <br>
<br>-module(area_server0).<br>-export([loop/0]).<br><br>loop() -><br> receive<br> <b>{rectangle, Width, Ht}</b> -> % tuple here<br> io:format("Area of rectangle is ~p~n" ,[Width * Ht]),<br>
loop();<br> {circle, R} -><br> io:format("Area of circle is ~p~n" , [3.14159 * R * R]),<br> loop();<br> Other -><br> io:format("I don't know what the area of a ~p is ~n" ,[Other]),<br>
loop()<br> end.<br><br>Here we uses tuples to send/receive messages, but when I change them to list, the codes still work.<br><br>loop() -><br>
receive<br>
<b>[rectangle, Width, Ht]</b> -> <br> ... % Still works as long as we agree to use list to send the message.<br><br>So I was wondering does this mean either tuple or list is ok or there is still some difference between them ?<br>
<br>Thanks!<br><br>Qiulang<br> <br>