You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Essentially I create a global namespace table, and put functions onto that table. Then when calling functions from that table, whenever the table is modified (e.g. when reloading a file), the new version of the function is called.
I wanted to ask if this seems like a reasonable way to solve it, or if I'm missing something obvious here. :)
One alternative solution I came up with was somehow sharing the current environment, and putting things into it using (put-in env [:namespaces :ns-to-be-updated] :ref @[new-version-of-function]). It seems a bit more intrusive though.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I like to repl a lot, and one limitation I've found is that when working with multiple files, it seems like
varfn
doesn't work.E.g.
To solve this, one must also re-import the file depending on
vartest.janet
. This gets pretty crazy when you have many layers of dependencies.Therefore, I created an alternative way to add dependencies, inspired by how javascript modules work (example in repo): https://github.com/Saikyun/janet-namespaces
Essentially I create a global namespace table, and put functions onto that table. Then when calling functions from that table, whenever the table is modified (e.g. when reloading a file), the new version of the function is called.
I wanted to ask if this seems like a reasonable way to solve it, or if I'm missing something obvious here. :)
One alternative solution I came up with was somehow sharing the current environment, and putting things into it using
(put-in env [:namespaces :ns-to-be-updated] :ref @[new-version-of-function])
. It seems a bit more intrusive though.Beta Was this translation helpful? Give feedback.
All reactions