Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Charly lang embeded inside Crystal #167

Open
faustinoaq opened this issue Mar 28, 2017 · 4 comments
Open

Charly lang embeded inside Crystal #167

faustinoaq opened this issue Mar 28, 2017 · 4 comments

Comments

@faustinoaq
Copy link

faustinoaq commented Mar 28, 2017

Hi @KCreate

Would be possible to use Charly inside Crystal?

I mean:

require "charly"

puts Charly.run("2 + 2") # => 4

code = <<-CHARLY
print("hello world")
CHARLY

Charly.run(code) # => hello world
@KCreate
Copy link
Collaborator

KCreate commented Mar 28, 2017

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!

@faustinoaq
Copy link
Author

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

@KCreate
Copy link
Collaborator

KCreate commented Apr 2, 2018

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

@faustinoaq
Copy link
Author

faustinoaq commented Apr 2, 2018

Oh, @KCreate really nice! Thank you for sharing! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants