arr-ai / arrai

The ultimate data engine.
http://arr.ai
Apache License 2.0
20 stars 15 forks source link

@super #602

Open marcelocantos opened 4 years ago

marcelocantos commented 4 years ago

Please do not post any internal, closed source snippets on this public issue tracker!

Purpose

Please describe the end goal you are trying to achieve that has led you to request this feature.

As an extension to #485, support the special value @super, which refers to the lhs of a merge, either regular (some_tuple +> (y: @super.x + 1) equals some_tuple +> (y: some_tuple.x + 1)) or within special tuple/dict syntax (a +> (y+>: @super.x)) equals a +> (y+>: a.x))).

Chaining is not supported. Referring up the tree requires capturing in let forms:

some_tuple_expr +> (y+>: @super -> (z+>: @super.w + .x))

equals:

some_tuple_expr -> . +> (y+>: (z+>: .y.w + .x))

While the above hardly looks like an improvement, the existing syntax is still obviously not as clean

@super is purely a lexical construct. It is not part of the data model or execution model. Consequently, the following wouldn't work, because @super doesn't mean anything in the context in which it appears:

let merger = (y: @super.x + 1);
some_tuple +> merger

Suggested approaches

What have you tried, and how might this problem be solved?

The name @super was inspired by Jsonnet, from which this concept is lifted. A better name might be @lhs. I even considered just @, but I want to reserve that in case we implement the equivalent of Jsonnet's self, though that seems unlikely at this stage, since (a: 1, b: @.a + 1) can be trivially refactored as let a = 1; (:a, b: a + 1).