add record/2 to Typespecs

30 views
Skip to first unread message

eksperimental

unread,
Oct 12, 2016, 1:46:52 PM10/12/16
to elixir-l...@googlegroups.com
Hi,
I'm reviewing some documentation and I found this,

## Types

Types can be defined for tuples with the `record/2` macro (only available in
typespecs). This macro will expand to a tuple as seen in the example below:

defmodule MyModule do
require Record
Record.defrecord :user, name: "john", age: 25

@type user :: record(:user, name: String.t, age: integer)
# expands to: "@type user :: {:user, String.t, integer}"
end


And the Typespecs page has no mentiong about this record/2 macro.
should we add it there?

José Valim

unread,
Oct 12, 2016, 2:04:21 PM10/12/16
to elixir-l...@googlegroups.com
The record/2 macro is defined in the Record module so I would keep things contained in the Record module and not link it to in typespecs, specially because it is a regular Elixir macro and not a typespec construct.



José Valim
Skype: jv.ptec
Founder and Director of R&D


--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/20161013004644.74d672f9.eksperimental%40autistici.org.
For more options, visit https://groups.google.com/d/optout.

eksperimental

unread,
Oct 12, 2016, 4:12:32 PM10/12/16
to elixir-l...@googlegroups.com
great.
thank you

On Wed, 12 Oct 2016 20:03:59 +0200
José Valim <jose....@plataformatec.com.br> wrote:

> The record/2 macro is defined in the Record module so I would keep things
> contained in the Record module and not link it to in typespecs, specially
> because it is a regular Elixir macro and not a typespec construct.
>
>
>
> *José Valim*
> www.plataformatec.com.br
> Skype: jv.ptec
> Founder and Director of R&D
>
> On Wed, Oct 12, 2016 at 7:46 PM, eksperimental <eksper...@autistici.org>
> wrote:
>
> > Hi,
> > I'm reviewing some documentation and I found this,
> >
> > ## Types
> >
> > Types can be defined for tuples with the `record/2` macro (only
> > available in
> > typespecs). This macro will expand to a tuple as seen in the example
> > below:
> >
> > defmodule MyModule do
> > require Record
> > Record.defrecord :user, name: "john", age: 25
> >
> > @type user :: record(:user, name: String.t, age: integer)
> > # expands to: "@type user :: {:user, String.t, integer}"
> > end
> >
> >
> > And the Typespecs page has no mentiong about this record/2 macro.
> > should we add it there?
> >
> > --
> > 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-co...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages