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

Dynamic modules #170

Closed
bvssvni opened this issue May 16, 2016 · 0 comments
Closed

Dynamic modules #170

bvssvni opened this issue May 16, 2016 · 0 comments

Comments

@bvssvni
Copy link
Member

bvssvni commented May 16, 2016

Dyon uses dynamic modules to organize code.

List of included functions for dynamic modules

  • fn load(source_file: str) -> res
  • fn load_source_imports(source_file: str, imports: []) -> res
  • fn call(module, function_name: str, arguments: [])
  • fn call_ret(module, function_name: str, arguments: []) ->

call and call_ret can be unsafe to use if the function takes lifetimes (later changes to the language might address this).

What is a dynamic module?

A dynamic module is loaded at run-time, while running the program, instead of being parsed before running the program. When the module is loaded, you can call functions inside that module through call and call_ret.

Design

When Dyon imports a module X for a new dynamic module A, the module X becomes part of the prelude for A. This makes it easy to:

  • swap a back-end module without changing the source
  • rewrite functions in Rust without changing code
  • write loader scripts that refreshes a module while running the program
  • replaced need for eval, which might be easily insecure and make a mess
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

1 participant