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

Allow usage of some stdlib functions without an explicit import #2140

Closed
TomAFrench opened this issue Aug 3, 2023 · 3 comments
Closed

Allow usage of some stdlib functions without an explicit import #2140

TomAFrench opened this issue Aug 3, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@TomAFrench
Copy link
Member

Problem

#2137 adds an assert_eq builtin function which is more efficient than usage of the assert() keyword. It isn't very ergonomic for developers however as it must be imported from the stdlib explicitly.

// Compiles
use dep::std::assert_eq;

fn main(x: Field) {
    assert_eq(x, 3);
}

// Compile error
fn main(x: Field) {
    assert_eq(x, 3);
}

Happy Case

In an ideal situation we would have a list of stdlib functions which are imported into each Noir file by default.

An example list could be:

  • assert_eq
  • println

Alternatives Considered

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@kevaundray
Copy link
Contributor

The usual way to do this is via a prelude that gets imported automatically to every program.

First step would be to add a prelude file to stdlib and then have it only import the relevant items, then given that the stdlib is always available, the compiler will automatically include the prelude imports into every module.

@kevaundray
Copy link
Contributor

Changed priority to P-low since this is non-blocking and is the current workflow strategy

@TomAFrench
Copy link
Member Author

Closing in favour of #2361

@TomAFrench TomAFrench closed this as not planned Won't fix, can't repro, duplicate, stale Sep 27, 2023
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

2 participants