/proc/MyLib_Thing()
or
/datum/MyLib
var/global/datum/Mylib/MyLib = new
- both of which are somewhat ugly. The latter is impacted by world init order and if the former uses proc-static vars the same - plus inherent leaking of any shared values.
I'd love to have some kind of namespace marker that gates access to procs behind a prefix without needing an instance of something, proc name prefixes, or other specifically user code space strategies.
For example,
/static/Math
var/const/PI = 3.14159
proc/Floor(num)
return round(num)
proc/Round(num)
return round(num, 1)
...
var/indianaPi = Math.Floor(Math.PI)
where Math cannot be instantiated in user code and is accessible simply as Math, a magic global.
I believe this would help solve and improve several things:
The byond library ecosystem could be improved. Someone providing a function library can literally do that, rather than a mess of stuff and free variables or an awkward bring-your-own-instance.
Running /static/foo/New() prior to world/New and prior to *instantiable* types means you always have these things available (so long as they don't demand one another, but that's tomorrow's problem).
--
As a stretch idea related to "How to break world.init", a numeric initialization order member on datums would be neat. Given a default 0 and simply sorting everything that's created before world/New into groups according to that number, where within a group stuff is ordered the same as current, but groups are run in an order determinable by game authors.
The static keyword won't really work for this; that way lies madness. I also see no need to gate the proc and type names as such; I would much prefer if, instead, namespacing simply changed the way scope resolution was done so that 1) supplying a namespace would limit searches to within that space, and 2) any code within the namespace proper would prefer matches within the namespace.
For the most part what I have in mind might be fairly easy to do already, with one small problem: type paths would necessarily include the namespace in their path, which is far from ideal. And code like list += new/thing, where /thing is defined within the namespace, would then be unable to work without some significant help.