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

add lazy-import #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

AlexKnauth
Copy link
Collaborator

@AlexKnauth AlexKnauth commented Dec 10, 2021

This allows me to lazy-import certain libraries to be able to compile glow on WSL.

good enough for me to use to compile glow on WSL, anyway...
could be better though
better modpath resolving, temps to avoid name conflicts
@AlexKnauth AlexKnauth changed the title add initial implementation of lazy-import add lazy-import Dec 11, 2021
@AlexKnauth
Copy link
Collaborator Author

@fare Although Glow-Lang/glow#419 is no longer necessary, I still think lazy-import could be a good addition to gerbil-utils on its own.

@fare
Copy link
Collaborator

fare commented Dec 13, 2021

Maybe it could make it directly upstream in Gerbil? What does vyzo think? There would have to be more documentation, though.

@fare
Copy link
Collaborator

fare commented Dec 13, 2021

Looking at the code, it seems that it's only for functions. Is that the case?
That requires documentation, to say the least. Maybe a runtime check, if meaningful—also a check that the binding is present and of the right kind, etc.

In another way, the syntax looks like it is heavy in parentheses. Is there a good reason for that?

@AlexKnauth
Copy link
Collaborator Author

Yes, it's only for functions, inspired by how Racket's lazy-require is only for functions. That's documented here for lazy-require:

Defines each fun-id as a function that, when called, dynamically requires the export

@AlexKnauth
Copy link
Collaborator Author

The inspiration from Racket's lazy-require is also the reason for the parentheses being as "heavy" as they are.

@fare
Copy link
Collaborator

fare commented Dec 14, 2021

OK, but since we're not compatible anyway (due to it being called "lazy-import" rather than "lazy-require", and hopefully having the same syntax as import for naming modules as either symbols or strings (or isn't the latter the case?), can we skip the extra layer of parentheses around the names of the imported functions? Or going the other way, we could triple or quadruple the number of parentheses just to be sure.

@fare fare force-pushed the master branch 2 times, most recently from 62578a4 to 2c199c8 Compare October 3, 2023 20:05
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