Say I have a process loop with a receive block that receives a bunch of different messages...typical scenario:<br><br>loop(A, B, C)-><br>receive<br> {msg1, A1}-><br> loop(A1, B, C)<br>;<br>{msg2, B1}-><br> loop(A, B1, C)<br>
;<br>{msg3, C1}-><br> loop(A, B, C1)<br>
;<br>{msg4, A2, C2}-><br> loop(A2, B, C2)<br>end<br>.<br><br><br>Is there a shorthand way to avoid having to repeat the calls to loop so many times? I realize Erlang is functional and this is how you have to maintain state, but it gets tedious typing all that out. It's especially burdensome and error prone if I go back later and add or remove a parameter to loop, because then I have to change it everywhere else, too.<br>
<br>It'd be cool if I could say something like loop(_,_,C1) and have the compiler understand that I want to call loop with whatever the values of A and B currently are. <br><br>Or even better, some syntax like loop(A:A2,C:C2) and it would know I wanted to preserve B, but replace A and C with A2 and C2.<br>
<br>Is there any reason why something like this wouldn't be possible?<br>