Skip to content

An erlang parse_transform that automaticaly generates and exports accessors for all records declared within a module.

Notifications You must be signed in to change notification settings

dieswaytoofast/dynarec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

Dynarec

Parse transform that automaticaly generates and exports accessors for all records declared within a module.

It generates and exports the following functions:

get_value(field_name, Record) ->
    Record#record_name.field_name.

set_value(field_name, Value, 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{}.

from_map(record_name, Map) ->
    #record_name{...}.

to_map(Record) ->
    #{...}.

It runs at compile time using following preprocessor directive:

-compile({parse_transform, dynarec}).

All those functions are added to the module that uses the directive. Be aware that dynarec.erl must be compiled before any module that uses it.

About

An erlang parse_transform that automaticaly generates and exports accessors for all records declared within a module.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages