ethereum / moon-lang

Minimal code-interchange format
MIT License
193 stars 20 forks source link

Bang notation returns javascript. #29

Closed Kesanov closed 7 years ago

Kesanov commented 7 years ago
λ moon run "<(add 1)"
"1__0=>(()=>{var _main=__0;return _main})()"

λ moon run "|<(add 1)"
"1__0=>__0"
VictorTaelin commented 7 years ago

Woops! I'll take a look soon.

Edit: OK, so, that's a clear type error, because <(add 1) is syntax sugar to add 1 x => x. Moon has unspecified behavior when there is a type error such as looking up a key not present in a map, or calling numbers on things. moon run "(add 1 x => x)" returns JavaScript too.

Changing that would need some runtime checks which could destroy the performance of the fast evaluator, for example, so I decided to just declare those things as unspecified behavior - you should in theory have checked your code before compiling it to Moon. Makes sense?

Kesanov commented 7 years ago

Oh I see. Would it be possible to have a command that evaluates a term to normal form ( add 1 a => a in this case), before trying to interpret it?