Let say I do have a record definition: -record(my, { a :: atom(), b :: binary()
}).
Are there any possibility to extract a metadata of record elements during run-time? E.g call_some_magic_fun that says R#my.a is atom, R#my.b is binary...
You'd need the abstract code available and then you can call dialyzer_utils:get_record_and_type_info/1 which returns a dict containing the type information. You can then pass this dict to various functions in the erl_types module to get back information about type specs.
If you don't want to rely on dialyzer at runtime, you'll need to copy-paste the code from dialyzer_utils AFAICT. Also the erl_types module is part of hipe.
On 27 March 2012 07:58, dmitry kolesnikov <dmkolesni...@gmail.com> wrote:
> Let say I do have a record definition: > -record(my, { > a :: atom(), > b :: binary() > }).
> Are there any possibility to extract a metadata of record elements > during run-time? E.g call_some_magic_fun that says R#my.a is atom, > R#my.b is binary...
We want to provide a simple API to one of our customers not very familiar with Erlang.
This API involves records manipulations (set/get operations) and you know what I mean.
> We want to provide a simple API to one of our customers not very
> familiar with Erlang.
> This API involves records manipulations (set/get operations) and you
> know what I mean.
It may seem a bit silly, but you could wrap element and setelement in macros that relate to the record name with short get/set names. That would probably make it simpler for those that are addicted to get/set.
> On 08/15/2012 03:04 AM, Zabrane Mickael wrote:
>> Hi guys,
>> We want to provide a simple API to one of our customers not very
>> familiar with Erlang.
>> This API involves records manipulations (set/get operations) and you
>> know what I mean.
> We want to provide a simple API to one of our customers not very familiar
> with Erlang.
> This API involves records manipulations (set/get operations) and you know
> what I mean.
> On Tue, Aug 14, 2012 at 10:04 PM, Zabrane Mickael <zabra...@gmail.com> wrote:
> Hi guys,
> We want to provide a simple API to one of our customers not very familiar with Erlang.
> This API involves records manipulations (set/get operations) and you know what I mean.
> On Tue, Aug 14, 2012 at 10:04 PM, Zabrane Mickael <zabra...@gmail.com> wrote:
> Hi guys,
> We want to provide a simple API to one of our customers not very familiar with Erlang.
> This API involves records manipulations (set/get operations) and you know what I mean.
>> On Tue, Aug 14, 2012 at 10:04 PM, Zabrane Mickael <zabra...@gmail.com> wrote:
>> Hi guys,
>> We want to provide a simple API to one of our customers not very familiar with Erlang.
>> This API involves records manipulations (set/get operations) and you know what I mean.
>>> It's very simple to use. The explanation is at the beginning of the file. There's also Ulf Wiger's exprecs module from his parse_trans application:
>>> On Tue, Aug 14, 2012 at 10:04 PM, Zabrane Mickael <zabra...@gmail.com> wrote:
>>> Hi guys,
>>> We want to provide a simple API to one of our customers not very familiar with Erlang.
>>> This API involves records manipulations (set/get operations) and you know what I mean.