[erlang-questions] RecordA serialization ... time ... deserialization to RecordB?

Juan Jose Comellas juanjo@REDACTED
Fri Nov 11 15:48:54 CET 2011

If what you need is a way to access record fields by name during runtime, I
have a module called dynarec in a project I'm working on that will very
easily allow you to do it. You can find it here:

Basically, what you do is add the following preprocessor directive to the
module where you keep your records:

-compile({parse_transform, dynarec}).*
And then on that module you'll get the following functions automatically
inserted for all the records (and their fields) that were defined in the

get_value(field_name, Record) ->

set_value(field_name, Value, Record) when is_record(Record, record_name) ->
    Record#record_name{field_name = Value}.

records() ->
    [record_name1, record_name2, ...].

fields(record_name) ->
    [field_name1, field_name2, ...].

new_record(record_name) ->

Hope it helps.


On Fri, Nov 11, 2011 at 5:31 AM, Max Bourinov <bourinov@REDACTED> wrote:

> Hello Erlangers,
> What is a best way to serialize record, modify record's code and then
> deserialize it back?
> I seen https://github.com/esl/parse_trans. Is this what I need or there
> are another options?
> Maybe I better use another data structure?
> p.s. Of course performance is always important.
> Best regards,
> Max
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111111/d8c6c5dc/attachment.htm>

More information about the erlang-questions mailing list