uhmanoa-transpiler-project / shaka-scheme

The official repository for the UH Manoa Transpiler Project's Scheme interpreter, Shaka Scheme.
32 stars 24 forks source link

Possible bug with DataNode not checking for nesting depth #11

Closed CinchBlue closed 7 years ago

CinchBlue commented 7 years ago

One of the problem with DataNode in core/base/DataNode.h is that its single-Data construct will automatically place the head into the DataNode's head 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 like is_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 value nullptr 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 one M(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).

CinchBlue commented 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).

CinchBlue commented 7 years ago

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.