Yes, that's also an option and in fact I am already doing it, because the event message also has all the information corresponding to a channel, and I keep this information as a separate tuple. The main benefit I see with parameterized modules is that I would be able to expose a generic interface for channel events and freely change the underlying representation without having to modify the modules that use them. It's not a huge benefit, but I would certainly use this feature if I had some certainty that it could suddenly disappear from the next version of Erlang.<br>
<br><br><div class="gmail_quote">On Tue, Jul 1, 2008 at 9:06 PM, Christian S <<a href="mailto:chsu79@gmail.com">chsu79@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">2008/7/1 Juan Jose Comellas <<a href="mailto:juanjo@comellas.org">juanjo@comellas.org</a>>:<br>
</div><div class="Ih2E3d">> The good thing about this feature is that it provides a way to have an<br>
> "encapsulated" record replacement.<br>
<br>
</div><div class="Ih2E3d">> The code that receives the events is unnecessary cumbersome because it needs<br>
> to work with a record within a record. If this was encapsulated within a<br>
> parameterized module, it would become much cleaner.<br>
<br>
</div>Nested records are not nice, no. For the record:<br>
<br>
make_stuff() -><br>
 #fs_channel_event{extra=#fs_channel_answer_event{write_codec_name=rot13}}.<br>
set_stuff(Ex) -><br>
  Ex2 = Ex#fs_channel_event{extra=(Ex#fs_channel_event.extra)#fs_channel_answer_event{read_codec_name=leetspeak}}.<br>
<br>
So the verbose syntax to do the above is what you want to avoid.<br>
<br>
<br>
<br>
Did you consider using an approach like the following instead?<br>
<br>
AnswerEvent = {#fs_channel_event{}, #fs_answer_event{}}<br>
HangupEvent = {#fs_channel_event{}, #fs_hangup_event{}}<br>
<br>
It's easy to deconstruct a tuple in pattern matching. You dont get the<br>
nesting above.<br>
<br>
make_stuff() -><br>
  {#fs_channel_event{}, #fs_channel_answer_event{write_codec_name=rot13}}.<br>
set_stuff({A, B}) -><br>
   {A, B#fs_channel_answer_event{read_codec_name=leetspeak}}.<br>
</blockquote></div><br>