Ark icon indicating copy to clipboard operation
Ark copied to clipboard

Bug: https://github.com/ArkScript-lang/Ark/issues/337

Open Loki-Astari opened this issue 2 years ago • 1 comments

Issue:
    The search for symbols in the module in the global namespace does not find any values.
    Thus the symbol i snot inserted.

    Changed the code so that if it does not find the symbol then we insert it first.
    Then we can push the function name in all situations.

Loki-Astari avatar Nov 11 '21 21:11 Loki-Astari

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Nov 11 '21 21:11 CLAassistant

Hello :wave: It's been a while and I've finally come to the realization that this fix, as easy as it might look, wouldn't work for the REPL. The reason is that we would link all the symbols of a plugin, even if they aren't used, and create new symbols for them. However, when the user will send a new block of code, the code will be recompiled, the state will be erased (thus the plugin's symbols will be removed), and we will have binded some plugin's functions in the global scope, but maybe in the wrong place/order.

Let's say we have a plugin with the following functions:

  • one
  • two
  • three

And the following REPL:

> (import "plugin.arkm")
> (two "hello")  # here we will use the global symbol 0
                 # but it will be "one" as this would be the
                 # first one to be binded

An idea would be to reload every plugin in the REPL after line of code (this could be kind of slow, but the REPL isn't meant to be fast, and we are limited by the typing speed of the user). For this reason I'll close this PR, feel free to make a new one!

SuperFola avatar Sep 05 '22 12:09 SuperFola