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

stdlib import suggestions #450

Open
Akuli opened this issue Dec 14, 2023 · 5 comments
Open

stdlib import suggestions #450

Akuli opened this issue Dec 14, 2023 · 5 comments

Comments

@Akuli
Copy link
Owner

Akuli commented Dec 14, 2023

I just got this error

compiler error in file "../grid.jou", line 32: function 'strdup' not found

Would be nice if these errors suggested where to import the function from, e.g. function 'strdup' not found, consider importing "stdlib/str.jou"

@littlewhitecloud
Copy link
Contributor

I have a idea. We can use syntax like C/C++.
For example:

import <str.jou>  # This will import from stdlib
import "test.jou" # This will import at local

This syntax has some advantages

  • Write less words
  • If there is a filename as same as the filename in stdlib, you can import them all
  • Less check

If we can remove .jou suffix, it will be nicer

@Akuli
Copy link
Owner Author

Akuli commented Dec 16, 2023

I have considered this in the past, and decided to do what Jou does now, for a few reasons:

  • import "stdlib/test.jou" is easier to parse, because it is just a keyword and a string
  • I want Jou users to look in the stdlib/ folder, and if the import mentions stdlib/foo.jou, it is very obvious what file it is importing and from where
  • In the future there might be a libs or deps folder where third-party dependencies of your project go. Then you would do import "libs/joujson/json.jou". In C/C++, < is confusing because it can mean standard library or third-party.

And here's why imports have the .jou suffix:

  • It makes it obvious to users what the import does, and how to find the file being imported
  • It simplifies the compiler (though only a little bit)

@littlewhitecloud
Copy link
Contributor

Hmm, alright, just a idea.

@Akuli
Copy link
Owner Author

Akuli commented Dec 17, 2023

I should document imports, and explain in docs why they are like they are :)

@Moosems
Copy link

Moosems commented Dec 24, 2023

Would be nice if these errors suggested where to import the function from, e.g. function 'strdup' not found, consider importing "stdlib/str.jou"

I don't know personally, this always felt like too much automagic.

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

3 participants