[erlang-questions] Runtime checking for types
Ken Robinson
kenrobinsonster@REDACTED
Sun Apr 17 17:11:30 CEST 2011
I know this sounds crazy but I was wondering if there was some runtime
check for types. I've created an abstract data type in an .erl (see
below). I want to now pattern match
-opaque u16int() :: 0..(1 bsl 16 - 1).
-export_type([u16int/0]).
...
-record(headerrec, {message_id :: u16int()}).
-opaque headerrec() :: #headerrec{}.
-export_type([headerrec/0]).
I can do a runtime test like so:
foo(#headerrec{} = HeaderRec) ->
...
What I would like to do is test for the new type similar to the gaurds
is_record() and the like. Any ideas? I realize I can put this all in a
.hrl file but this would break the encapsualtion.
regards,
Ken Robinson
Mob +61438681120
Home +61738523767
More information about the erlang-questions
mailing list