Klebert-Engineering / simfil

The Simple Map Filter Language Interpreter 🌳.
BSD 3-Clause "New" or "Revised" License
6 stars 0 forks source link

Value with ModelNodePtr should not evaluate to null #12

Closed josephbirkner closed 1 year ago

josephbirkner commented 2 years ago

Currently, a Value which holds a ModelNode always evaluates to false, because the Value::field() ctor requires an existing value which is always null for for objects/arrays. This leads to some confusion, because myModel.objectNode is never true and trace(myModel.objectNode) always returns null. The only way to evaluate a compound member as true is through the exists-operator, but that seems like an unnecessary constraint.

The Value can also assume an Object state. Maybe we can replace Object with ModelNodePtr? Then ObjectModelNode::value() wouldn't need to return null anymore, and the ::field ctor can be removed. We can give the ModelNode interface a meta() function to unify Object and ModelNode.