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

Separation of stdlib #806

Closed
wants to merge 3 commits into from
Closed

Conversation

DaddyWesker
Copy link
Contributor

So, some modularity for stdlib is here. I've created two new modules for common tokens and runner tokens and extracted functions to those modules alongside with tests for those functions.

I've also made run_program in stdlib_minimal/mod.rs::tests pub to use it in separate modules' tests instead of copy-pasting run_program to each new module. I'm not sure if this is right decision, but it seems more elegant to me.

@DaddyWesker DaddyWesker requested a review from vsbogd November 21, 2024 09:43
@DaddyWesker DaddyWesker changed the title Separate stdlib Separation of stdlib Nov 21, 2024
Copy link
Collaborator

@vsbogd vsbogd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably I should be more specific and provide some examples when we were discussing it. Separating functions in stdlib on "common tokens" and "runner tokens" sets doesn't make much sense because it is technical difference. "common" set of tokens is registered only once on loading root MeTTa runner because they doesn't depend on space and metta. "runner tokens" should be reloaded each time new MeTTa module is imported. Thus for example assert... and import! are both in "runner tokens" set while semantically they are different.

Thus I would suggest starting from scratch and consider functions from both "common" and "runner" token sets as a single list. I would suggest then make a commit to finally separate "math" module. We could add a register_common_tokens() function implementation into stdlib_math.rs and put all math tokens into it. then call this new stdlib_math::register_common_tokens() from stdlib::register_common_tokens(). After this stdlib_math module will be more or less separated.

Then I would start trying to figure out which new kinds of modules can be added. For example:

  • random module: random-... and flip
  • atom module: get-...type..., ...-atom, sealed
  • module module: import!, include, bind!, mod-space!, print-mods!
  • package module: pkg_mgmt functions;
  • string module: println!, format-args
  • debug module: trace!, print-alternatives!
  • space module: new-space, add-atom, etc, get-atoms

BTW, stdlib_minimal/mod.rs includes unit tests for stdlib_minimal.metta part of library. Thus tests for functions like cons-atom could also be moved into atom module, etc

@@ -1,27 +1,27 @@
#[macro_use]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

Suggested change
#[macro_use]

@@ -1,27 +1,27 @@
#[macro_use]
pub mod stdlib_math;

#[macro_use]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[macro_use]

#[macro_use]
pub mod stdlib_common_tokens;

#[macro_use]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[macro_use]

@DaddyWesker DaddyWesker deleted the separate_stdlib branch November 22, 2024 04:30
@DaddyWesker DaddyWesker mentioned this pull request Nov 28, 2024
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