Closed monkoose closed 3 years ago
That's okay! And a good question, so if it's private it can't be accessed by normal means, same as Clojure etc.
When private not even the test file can see it since it's just a regular old module, even though it shares part of the name, they don't have special access to the contents.
I think it is actually exposed in aniseed's internals which you can see by requiring the module and printing / inspecting the result of the require.
But I'm not sure I'd recommend that, personally I'd either just make it public or move it to an "impl" module below the main public one which can be tested and I'd clearly a set of internal functions users shouldn't rely on.
I've tested private functions in Clojure in a few different ways before (there's some semi hacks you can do) and usually regretted it.
So I'll either make them public (maybe in another implementation module) or I'll test my private fns through my public ones, relying on the higher level function as my interface.
I hope this helps!
On Mon, 28 Jun 2021, 23:43 monkoose, @.***> wrote:
Hello, sorry to disturb without an actual issue. But i don't have a discord account to ask there.
Is there any way to make local functions defined with defn- in some other module available in test module? Or just how to test local functions?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Olical/aniseed/issues/52, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACM6XOI5ROACMKZ7JFDRUTTVD3IHANCNFSM47O4Q4RQ .
Thank you for your answer.
Can be something done to ignore some functions at compile-time in a module? So you can test inside the module and just skip them at compiling? Macro or something? Something like rust's #[cfg(test)]
attribute. Sorry i'm new to lisp family languages.
Hmm not sure about that, I don't think I'd recommend it even if I could think of a way. I don't think the question makes complete sense in this context but maybe I'm misunderstanding!
I think your best bet is keep private truly private or just make everything public. I only really make private where I reaaaaaly don't want people relying on my internals for some specific reason.
I think a separate module / file like "mymod" and "mymod.impl" is the way to go personally. If people rely on your internals and you change them, that's their fault for ignoring the warning 🙂
On Tue, 29 Jun 2021, 11:40 monkoose, @.***> wrote:
Thank you for your answer.
Can be something done to ignore some functions at compile-time in a module? So you can test inside the module and just skip at compiling? Macro or something? Sorry i'm new to lisp family languages.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Olical/aniseed/issues/52#issuecomment-870479187, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACM6XP3URDCGN63E35JKBDTVGOVXANCNFSM47O4Q4RQ .
Ok. Closed.
Just one last question.
Is it more costly (in time consumption) to autoload
module with a lot of public functions, if you need only one function from it or it loads full module either way?
Thank you for answers, aniseed and conjure. Great work.
More costly than requiring without the autoload thing? Or do you mean does it incur cost? Because there will be a small amount of time to find the file on the package.path, read, parse. But not much at all, and every module in Lua is only loaded once then cached.
So 10 autorequires of the same module only incur the cost once. Does that help?
On Tue, 29 Jun 2021, 11:55 monkoose, @.***> wrote:
Closed #52 https://github.com/Olical/aniseed/issues/52.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Olical/aniseed/issues/52#event-4952745437, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACM6XKBXXEQNJCBOOFROV3TVGRB7ANCNFSM47O4Q4RQ .
Hello, sorry to disturb without an actual issue. But i don't have a discord account to ask there.
Is there any way to make local functions defined with
defn-
in some other module available in test module? Or just how to test local functions?