[erlang-questions] Are recursive record definitions allowed?
Maria Christakis
mchris@REDACTED
Wed Jul 28 09:36:04 CEST 2010
On 07/27/2010 10:28 PM, Brian Williams wrote:
> I'm working on some algorithm analysis and am trying to define a
> fairly simple binary search tree with a record definition:
> -record(btreenode, {left = #btreenode{}, right = #btreenode{}, value}).
> I get:
> record btreenode undefined
>
> Should I just not bother to specify the type of left and right and
> just enforce the record type in code?
>
>
If, as you say, you are just trying "to specify the type of left and right"
and not assign an initial (default) value, then you should write your
record definition as follows:
-record(btreenode, {left :: #btreenode{}, right :: #btreenode{}, value}).
More information about the erlang-questions
mailing list