Unfortunately, haschildren(x) was a terrible name because it's not testing the same thing as numchildren(x) == 0!
In our ASTs
Leaves of the tree correspond to tokens in the source text
Internal nodes are containers for a range of tokens or other internal nodes.
Occasionally we can have internal nodes which have no tokens and thus have numchildren(node) == 0. These are, however, still "internal nodes" and we have haschildren(node) === true for these which makes no sense!
Unfortunately,
haschildren(x)
was a terrible name because it's not testing the same thing asnumchildren(x) == 0
!In our ASTs
Occasionally we can have internal nodes which have no tokens and thus have
numchildren(node) == 0
. These are, however, still "internal nodes" and we havehaschildren(node) === true
for these which makes no sense!