goyamp
goyamp copied to clipboard
Enhance dot notation to allow nested expressions
Consider this case:
define:
$data1:
atom1: 12
atom2: 13
$data2:
items:
atom2
---
$data1,$data2.items
We get an error
Error: Subvariable value { items : atom2 } for not string or int in $data1.$data2.items
because this is being interpreted as `$data1,($data2).items.atom2
The workaround is to declare an intermediate variable:
define:
$data1:
atom1: 12
atom2: 13
$data2:
items:
atom2
---
define:
$inter: $data2.items
---
$data1.$inter
This enhancement is to add sub-expressions to make the evaluation order explicit such as
$data1.[$data2.items]
Thereby eliminating the intermediate variable.
This is a good idea because it saves programmer time. However, I had a look at the code changes needed - I will need a proper parser for dot notation, not just a string.split(). Let me know how important this enhancement is to you...