Non preprocessed E2 api #2759
Replies: 3 comments 2 replies
-
Global metamethod magic would just look so nice, to have E2 functions defined so seamlessly. |
Beta Was this translation helpful? Give feedback.
-
Something that needs to be considered is handling E2 libraries that expose things globally/to Wirelib. Maybe that's more of a fault of the libraries though. |
Beta Was this translation helpful? Give feedback.
-
Thinking about it again, maybe we could just copy SF's way of doing it. E2 will require (re)writing a documentation generator for it, anyway. Simplifying function definitions to not be a mess to maintain for us will be better. Could also coincide nicely with #3071; let legacy (preprocessed) function definitions continue to use the old path and new function definitions to use the new one. |
Beta Was this translation helpful? Give feedback.
-
The extension preprocessor has caused a lot of pain throughout the years with breaking editors.
So a pure lua api to create E2 extensions would be quite nice.
It's possible that this simple Emmylua/LuaLS annotated code could work as an extension, registering a function
test(sn)
How would it work? First, to know what functions are being defined in the first place, extensions would be run in an fenv that detects exporting functions (via __newindex). Second, to actually get information about the function, debug.getinfo could be used to read the file, and scan the emmylua annotations provided to the function.
So this works perfectly fine, but the question is whether this is perfectly sane:
Already this causes a linting error from exporting a global with a lowercase name, and this doesn't immediately look like you're exporting an E2 function, which may be very problematic, so, two alternatives could be done, either:
or
As for methods, likely a registerMethod function would be needed for the last two examples, the first one could theoretically also look like this with more metamethod magic, but it feels unholy at this point:
Another idea I had a while back was to have types shared as objects, and you'd reference them this way, so the same idea except instead of depending on the fenv, use the proper type, which is not as hacky.
Both of these don't type the
self
variable in your editor, however.Creating this discussion far in advance so we can get opinions on how this api should look. This would be the final api for E2, after all so it should be quite future proof.
Beta Was this translation helpful? Give feedback.
All reactions