Closed CinchBlue closed 7 years ago
DataNode's implementation is changing due to the evaluation model changing. We must re-evaluate whether this class still has a home in the new evaluation model (and it probably will).
DataNode will be replaced by DataPair with our new re-write of the core evaluation system. Data has also moved away from boost::variant
in favor of a hand-written tagged union class for reducing compile times, dependency download times, and reducing dependency on Boost.
One of the problem with
DataNode
incore/base/DataNode.h
is that its single-Data
construct will automatically place thehead
into the DataNode'shead
space without checking what exactly it is.This means that it is valid to do this:
make_node(make_node(make_node(Number(1))))
But, when you print it out, it will print out nothing, because the
operator<<
relies on the assumptions made by the predicates likeis_pair()
. This means that it is completely missed by the logic when printing it out.Funny thing enough, it will not be detected by a pair, because it is, indeed, considered as a single-value
DataNode
but it may hold a list as its single value. It's confusing.Possible fixes
I tried to change the constructor so that it will only construct with
NodePtr
that are of the valuenullptr
for single values, but this causes test cases to fail. More research needs to be done into this, as this implies that this is being done somewhere, but I myself do not know where.Another way is to dynamically detect and fix any "nesting," similar to how some monads fold two
M(M(value))
into oneM(value)
. This is run-time performance cost, however, and therefore, is not the favorable solution (although the detection part may help us understand when such a thing is being used).