Skip to content

Dynamic modules #170

Closed
Closed
@bvssvni

Description

@bvssvni

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions