Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

Standard Library (built-in modules) #74

Open
Rudxain opened this issue Apr 6, 2024 · 1 comment
Open

Standard Library (built-in modules) #74

Rudxain opened this issue Apr 6, 2024 · 1 comment

Comments

@Rudxain
Copy link
Member

Rudxain commented Apr 6, 2024

What it is

These are just *.rickroll files that the interpreter can conditionally embed into userland *.rickroll files. They are assigned to a special namespace, which the interpreter/compiler knows exactly where to locate unambiguously.

What it ISN'T

This isn't a generalized module system, as there's no support for userland scripts. This shall be implemented in a separate proposal (#75), for simplicity's sake.

Why

  • Portability
    • RR programs would no longer need 3rd-party lang-specific libraries, so they can work exactly the same on any implementation.
  • Abstraction
    • Everything is self-contained.
  • Fun!
    • We'll have freedom to name modules however we want! Example: core.math.pie is the π constant from the math module.

How

The implementation details are yet to be stabilized. I have a rough idea of how we could do it: RR modules would be inlined in a C-like manner, which is quite simple, but not perfect.

The reason behind a "special namespace" for built-in modules, is to simplify the module-resolution algorithm for when we add support for userland RR libs:

  • Userland libs would be imported using file-system path-string-literals, such as we know the "./FILE_NAME" and we're gonna play it (notice how the extension is optional)
  • Built-ins would be imported using similar (maybe exactly the same?) syntax as we know the std.MOD_NAME and we're gonna play it (notice the prefix to disambiguate between C/Py and built-in)

We could take inspiration from Rust by having different namespace-prefixes:

  • core
    • for self-contained stuff, such as
      • math processing
      • string formatting
      • list iteration and sorting
      • etc...
  • std
    • for abstractions over platform-specific and impl-specific code, such as

std would CONSIDERABLY reduce the need for importing Py libs/mods such as sys and os

Outro

I'm willing to contribute modules. We could even use stuff from the examples folder as a starting point. Even better, core/std could become examples themselves!

This was referenced Apr 6, 2024
@Rudxain Rudxain changed the title Standard Library and built-in modules Standard Library (built-in modules) Apr 6, 2024
@SatinWukerORIG
Copy link
Member

I have read all your issues, and I think your proposal is amazing. I haven’t worked on this for a long time, and I am ready to accept the challenge to rewrite in Rust 👍
I will start building a standard library, and thank you for all these issues!

@Rudxain Rudxain mentioned this issue Apr 7, 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

No branches or pull requests

2 participants