conversational-interfaces / dms-compiler

Compiles DM Script to DMPL JSON
https://w3c.github.io/dms/
5 stars 0 forks source link

Feature/issue7 8 9 10 #12

Closed victorzhangyf closed 4 years ago

BinRoot commented 4 years ago

It appears act pref({a: 1}) compiles to

{"@do":
    [ {"@act": {"type":"Spread", 
        "elements": [
            ["",{"`a`":1},{"`a`":4}],
            ["",{"`a`":1},{"`a`":-2}]
        ], 
        "__spread":true
        }}
    ]
}

Could you look into that?

Thank you!

victorzhangyf commented 4 years ago

I think pref is designed to be used inside an array right now. pref can generate multiple items: pref({a:1}) is equivalent to [{a: 1},{a: 4}] and [{a: 1},{a: -2}]. The generated items can all be appended to the enclosing array. act [pref({a: 1})] behaves as expected.

It is a bit tricky to also support pref outside an array, since sometimes we would need to append the generated items to the enclosing array, and sometimes we need to create a new array.

BinRoot commented 4 years ago

Got it, makes sense! Thanks!