Couldn't you define a method like __record_keys__/0 on the atom in the
defrecord call?

Allen Madsen
http://www.allenmadsen.com


On Sat, Dec 15, 2018 at 11:49 AM <wojtek.m...@plataformatec.com.br> wrote:

> One way to avoid issues with state is to avoid... state. Maybe we'd
> configure it like this:
>
> records = [
>   # explicit
>   {:column_definition, [:name, :type]},
>
>   # grabs record fields from record macro in that module, e.g:
> resultset(resultset()) |> Keyword.keys()
>   {Records, :resultset}
> ]
>
> IEx.configure(inspect: [records: records])
> ExUnit.configure(inspect: [records: records])
>
> This is less convenient, but I guess sometimes we may prefer the "tuple"
> representation so by making this opt-in we cater to that use case as well.
>
> On Saturday, December 15, 2018 at 5:08:13 PM UTC+1,
> wojte...@plataformatec.com.br wrote:
>>
>> Hello,
>> I'd like to discuss support for Inspect protocol for records. I created a
>> proof-of-concept here: https://github.com/wojtekmach/record_inspect
>>
>> Basically, for these records:
>>
>> defrecord :resultset [
>>   :column_count,
>>   :column_definitions,
>>   :row_count,
>>   :rows,
>>   :warning_count,
>>   :status_flags
>> ]
>>
>> defrecord :column_definition41, [:name, :type]
>>
>> Instead of:
>>
>> {:resultset, 2,
>>  [{:column_definition41, "2*3", 8}, {:column_definition41, "4*5", 8}], 1,
>>  [[6, 20]], 0, 2}
>>
>> We could get this:
>>
>> #resultset([
>>   column_count: 2,
>>   column_definitions: [
>>     #column_definition41([name: "2*3", type: 8]),
>>     #column_definition41([name: "4*5", type: 8])
>>   ],
>>   row_count: 1,
>>   rows: [[6, 20]],
>>   warning_count: 0,
>>   status_flags: 2
>> ])
>>
>> My proof-of-concept uses the new `:persistent_term` facility in OTP 21.2
>> just to get something working. Managing the state is challenging for
>> potentially including this in Elixir.
>>
>> Feedback appreciated!
>>
> --
> You received this message because you are subscribed to the Google Groups
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elixir-lang-core+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/8e936469-e806-46f9-b4a4-3aa3c577d205%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/8e936469-e806-46f9-b4a4-3aa3c577d205%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAK-y3Ct-2iFCY12qQD07GurkkRepiN3vqaDVgML_7WpHctqLuA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to