erde-lang / erde

A programming language that compiles to Lua.
https://erde-lang.github.io
MIT License
38 stars 4 forks source link

Print results in REPL like in Lua #12

Closed tp86 closed 1 year ago

tp86 commented 1 year ago

I have played with REPL a little bit and attempted to get consistent behavior between Lua and Erde.

In REPL before:

$ erde
Erde 0.5-1 on Lua 5.4 -- Copyright (C) 2021-2023 bsuth
> f = () -> (nil, 2, nil)
> f()
> 

In REPL after:

$ erde
Erde 0.5-1 on Lua 5.4 -- Copyright (C) 2021-2023 bsuth
> f = () -> (nil, 2, nil)
> f()
nil 2   nil
>

Lua REPL for comparison:

$ lua
Lua 5.4.4  Copyright (C) 1994-2022 Lua.org, PUC-Rio
> f = function() return nil, 2, nil end
> f()
nil 2   nil
> 

Additionally, it fixed return values from erde.run: Before:

$ lua
Lua 5.4.4  Copyright (C) 1994-2022 Lua.org, PUC-Rio
> erde = require('erde')
> erde.run('return nil, 2, nil')
nil 2
> 

After:

$ lua
Lua 5.4.4  Copyright (C) 1994-2022 Lua.org, PUC-Rio
> erde = require('erde')
> erde.run('return nil, 2, nil')
nil 2   nil
> 
tp86 commented 1 year ago

Will be done in another PR (#13)