The good thing about this feature is that it provides a way to have an "encapsulated" record replacement.<br><br>I have a library that I have built that acts as a client to FreeSWITCH (an open source telephony switch). I'm connected to FS over a socket where I get telephony events in an HTTP-like text protocol. These events have lots of fields (sometimes over 50) so it's necessary to keep their information in records. The problem is that some of these events share some fields. To avoid code duplication I use one function to parse common fields and another one to parse event-specifc data. To make this work I keep the channel data in a record and in a field of this record I keep another record with the event-specific data.<br>
<br>For example, whenever a channel is answered or hung up I get an event. As these two events are related to a channel, they share some fields, which I keep in an fs_channel_event record. This record has a field called
'extra' where I keep another record with the fields that are not common. These are a simplified version of the records:<br><br>% Generic channel event.<br>-record(fs_channel_event, {<br> name,<br> provider,<br>
timestamp,<br> channel_id,<br> channel_state,<br> answer_state,<br> call_direction,<br> %% Field where we keep a fs_channel_answer_event or a <br> %% fs_channel_hangup_event.<br>
extra<br> }).<br> <br>% Channel answer event.<br>-record(fs_channel_answer_event, {<br> read_codec_name,<br> read_codec_rate,<br> write_codec_name,<br> write_codec_rate<br>
}).<br> <br>% Channel hangup event.<br>-record(fs_channel_hangup_event, {<br> hangup_cause<br> }).<br><br>The code that receives the events is unnecessary cumbersome because it needs to work with a record within a record. If this was encapsulated within a parameterized module, it would become much cleaner.<br>
<br><br><br><div class="gmail_quote">On Tue, Jul 1, 2008 at 11:59 AM, 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;">
2008/7/1 Juan Jose Comellas <<a href="mailto:juanjo@comellas.org">juanjo@comellas.org</a>>:<br>
<div class="Ih2E3d">> An does anybody know what would it take to make this feature<br>
> official/supported? It is really useful in some cases.<br>
<br>
</div>Can you provide examples of how it is useful?<br>
</blockquote></div><br>