Search code examples
typeserlangrecordsbuilt-in

Erlang verify that record type exists?


Is there a way to verify that a record of a given type exists in an Erlang module? A function that would work something like this:

=> record_type_exists(robot).
true

Does such a function exist anywhere in Erlang?

Thanks in advance!


Solution

  • No, there is no such function.

    Records are a compile time feature in Erlang, so whether a record type "exists" or not depends on whether the compiler can find it (in the module itself or in an included header file) when compiling the given module. This is similar to how structs work in C.