SwissalpS / minetest_mooncontroller_libraries

Libraries that can be loaded from the in-game mooncontroller
MIT License
1 stars 0 forks source link

naming convention #1

Open SwissalpS opened 1 year ago

SwissalpS commented 1 year ago

Question A

Currently I have named the libraries with very short names:

This soon raises a namespace issue when another mod also provides libraries with the same names. It wil be a race condition which one gets set in the mooncontroller.luacontroller_libraries table.

So once the name of this mod is decided, we might be able to add namespace:

For now I could easily live with: SwissalpS:string but that isn't a very bright idea considering the option to maintain in mt-mods or similar in the future.

Related Question B

For now require('string') will just return a table with the string functions, leaving it to the user if he wants to assign it to a global or local variable. (or only parts of it to global space). While require('string_env') returns the same table but also adds the functions to env.string.

Does this naming make sense or should the default be adding to env? So string_env would be just string and what currently is string would be something like string_raw.

If so, what would a good name instead of raw be?

All suggestions and ideas apreciated, thanks.

S-S-X commented 1 year ago

I think _raw stuff probably shouldn't be there at all. And that basically also makes _env stuff completely unnecessary. Having all that probably just complicates things without any real reason to do so, I'm pretty sure it would be a lot better to define single backwards compatible API for extensions.

To give access to raw just do not load extensions and to apply extensions to string just require("string_extensions")

For possible race conditions I don't think there's need to solve it here and it would be better to do this with we're all adults here mindset instead, I mean maybe guidelines but no restrictions.

Only good libraries will be installed anyway, I think that's well enough to limit what would be added and what wont be added.

There might be some issues with this, mainly if "self-regulation" (of extensions) fails for any reason but for most stuff, even small things, it seems to work very well.

SwissalpS commented 1 year ago

Thanks for your input.

To give access to raw just do not load extensions and to apply extensions to string just require("string_extension")

I don't quite understand what you mean here. Without require('extension') luaC has no access to any of extension functions.

I mean maybe guidelines but no restrictions.

Yes, guidlines in mooncontroller docs would be great, so we don't totally work in different ways. Users apreciate consistency.

Klaranth commented 1 year ago

So, let see if I get this .... Raw is basically version zero? And which other conventions on naming are there?

SwissalpS commented 1 year ago

Raw is basically version zero?

no, raw is just a bad name for saying that when you local v = require('vector_raw'), v will contain a table with the vector functions whereas if you do local v2 = require('vector_env'), v will have the same contents as v but the env will also contain it -> there is a global calledvector``.

A user may want _raw variant because he has already got a global called 'vector' or his code only sometimes needs vector functions and the other times he wants to keep global space slim.

Klaranth commented 1 year ago

Out of curiosity, did you ask ChatGPT for input? :)

SwissalpS commented 1 year ago

nope, I like human input :D