Open faustinoaq opened 7 years ago
Should be possible, but I'm not sure how it should behave. Charly loads a prelude file on startup, so it would need to be run every time to make sure you always run off a blank slate.
Another option would be to instantiate a dedicated Charly object that would handle these things.
What I mean:
require "charly"
vm = Charly.new
vm.run "2 + 2" # => 4
code = <<-CODE
print("hello world")
CODE
vm.run code # => hello world
Something similar to this is also included inside Issue #154.
Thanks for the suggestion!
Hi, nice shard here: https://github.com/veelenga/lua.cr
It works very similar to you comment sample:
lua = Lua.load
sum = lua.run %q{
function sum(x, y)
return x + y
end
return sum
}
p sum.as(Lua::Function).call(3.2, 1) # => 4.2
lua.close
Hey, that looks really nice, something like that was exactly what I had in mind. I'm currently devoting most of my development to a new c++ virtual machine for the Charly programming language and will mostly likely deprecate the Crystal version once the VM is finished.
If you're interested in that, please take a look at the new project: KCreate/charly-vm
Oh, @KCreate really nice! Thank you for sharing! :tada:
Hi @KCreate
Would be possible to use Charly inside Crystal?
I mean: