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

Load new operators at runtime #125

Merged
merged 4 commits into from
Dec 31, 2024
Merged

Load new operators at runtime #125

merged 4 commits into from
Dec 31, 2024

Conversation

nick-paul
Copy link
Collaborator

@nick-paul nick-paul commented Dec 31, 2024

This is a continuation & modification of #111

I changed the loading process to an operator instead of loading from the libs folder on startup. This was a suggested option in the original PR. To load additional operators, you can use the :(library.load) named operator.

I went with :(library.load) instead of auto loading from libs because I prefer to allow Aya code to have more control over how and when to load libraries at runtime. This will be useful for adding a package manager or improving importlib.

Example

For an example, check out the example library based off the sample library provided in the original PR here:

https://github.com/aya-lang/aya-library-example

aya> "path/to/aya-library-example-1.0-SNAPSHOT.jar" :(library.load)
[ ":(example.instruction)" ":(example.instruction2)" ]
aya> :(example.instruction)
"hello, world"
aya> :(example.instruction2)
"foo bar"

You can also use the import statement to load the jar. This will not return the list of loaded operators

aya> import "path/to/aya-library-example-1.0-SNAPSHOT.jar"
aya> :(example.instruction)
"hello, world"

@nick-paul nick-paul merged commit 4a02a79 into master Dec 31, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants