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

Jesse Gumm gumm@REDACTED
Fri Nov 11 18:47:32 CET 2011


Juan,

That's really cool man. I dig it, and still find some way to incorporate
that into singer if my projects.

Thanks,

-Jesse

--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866
www.sigma-star.com
@jessegumm
On Nov 11, 2011 8:49 AM, "Juan Jose Comellas" <juanjo@REDACTED> wrote:

> 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:
> https://github.com/jcomellas/mlapi/blob/master/src/dynarec.erl
>
> 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
> module:
>
> get_value(field_name, Record) ->
>     Record#record_name.field_name.
>
> 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) ->
>     #record_name{}.
>
> Hope it helps.
>
> Juanjo
>
>
>
> 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
>>
>>
>
> _______________________________________________
> 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/a16d9d0d/attachment.htm>


More information about the erlang-questions mailing list