Closed katawful closed 2 years ago
I worked around it by using defn
functions that return the values that I need to be updated. Not ideal, but it works
Sorry about the lack of response, I'm away this week and have been really struggling for time recently. I never intended to support def
etc from anywhere other than the top level of the file in the exact same way Clojure doesn't intend for people to use def to redefine things. That's just not how it's designed.
The best approach would be to use (defonce state {})
or something similar then update values in that state table that people can access, in my opinion. I've never tested nested defs and do not intend for it to work fundamentally. Sorry if this causes any issues! And maybe the main problem here is documentation, I could be explicit about what these macros are for.
That's understandable. My workaround is very similar to what you're suggesting anyways, but more explicit documentation would be useful for sure when you have the time
Added some more notes to the help text, hope that helps people in the future! Thanks for pointing this out!
I'm writing a colorscheme using Aniseed, and while using
def
s with modules is very convenient, if I were to update the colorscheme with different options (like doing::colorscheme my_scheme_dark
) during runtime, the color values I define withdef
are not updated like I expect (unlikedefonce
values). Snippet:I set the different color styles mostly using Vim methods. I compile a raw fennel file in
/colors
to the necessary Lua file which passes the color options to my main file's init function. These values do get passed properly doing some basic debug printing, but when it gets to the modules that contain my color variables these never actually update during runtime, only on boot. This makes me think that this is a bug in howdef
works (or maybe how autoload/require works?), since the documentation suggests thatdef
values can be overwritten on next eval:I have tried setting
def
values within a function that calls whenever these modules get requires/autoloaded, but that doesn't properly export these variables even though they do update properly.