-
Notifications
You must be signed in to change notification settings - Fork 30
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
Absolut import does not work. #141
Comments
Same for relative imports that do not use a dot in front of the imported module:
Files content:
And main.wren
Running main:
Does also not work if I'm in a different directory:
|
Not sure if it would help, but I largely rewrote all the module/importing code in my own CLI - it's now all pure Wren. Since Wren isn't re-entrant I run a second Wren VM to handle the more "complex" lifting to avoid as much low-level C. https://github.com/joshgoebel/wren-console I don't imagine it could be back-ported here though because it's a very different approach. |
Oh, that explains why you call the second VM "resolver VM". Did not realize it is a second VM, I thought it is an odd way of naming your variables. Well, the error is in your code (in wren-console, perhaps wren-cli works fine?). I guess I should have posted the issue in "wren-console"? Why is "not reentrant" a problem? I was about to extract the resolving and importing into a wren module as well, but then I realized it is mostly wren already. Is it generally not possible (not advised) to execute the VM and let foreign methods call back into the same VM? I had assumed it is enough to change the VM to first check if a wren module is registered to do the loading of an import, and if not call the function provided by the host. What am I missing? EDIT: I was thinking about working on two "APIs" aka "interfaces", one for wren code to call into the VM, aka writing a foreign class that resembles the VM, and one module for the VM to externalize everything that can be done in wren. That is basically how the Java Virtual Machine works. Nearly everything you would assume to be done by the VM is actually done in pure Java, e.g. Byte Code Verifying etc. Oki, I dig around - perhaps I can fix it, but for some reason (perhaps my post COVID problem) I have a hard time, lol. But it is fun anyway. |
Please do and I'd be happy to take a closer look.
Because importing is a hook in C... so you're stuck in C... and you can't enter the running Wren VM to run resolver code there since that would be re-entry - hence the second VM which we can enter freely even when the first VM is already running. |
See:
Source of the files (main.wren):
And the imported file:
Idunn2:absolut_import_bug angelos$ cat to_import.wren // the main.wren trys to import this with an absolut path System.println(" ... this fails - and is never printed")
Now running wrenc_d (debug version on my Mac, hence the _d)
Idunn2:absolut_import_bug angelos$ wrenc_d main.wren Could not load module './Users/angelos/development/kestrel-devel/absolut_import_bug/to_import'. at (script) (./main.wren line 1) Idunn2:absolut_import_bug angelos$
As you can see at the output: the resolving/loading adds an erroneous dot ('.')
I guess the culprit is this line in _wren.inc (around line 54):
SIMPLE should be ABSOLUT, or not?
EDIT: no, that is not the spot with the error - I investigate more.
The text was updated successfully, but these errors were encountered: