Replies: 2 comments 2 replies
-
|
So there are a few things here to break down but fundamentally half of the problem is the inconsistent global initialization order, and the inability to specify priorities of things like I do not want to remove these features because most C compilers even have such constructs for many rare edge cases that require them. And to break down each of the issues:
|
Beta Was this translation helpful? Give feedback.
-
|
+1 on this because would prefer deterministic code execution order in general OpenGL and SDL have required you to call their app-level init functions for years now Not that big a deal if odin base/core packages (or even third-party packages) demand the same (or employ an initialise-on-requirement model). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
@initand its relatives have caused a number of issues in the language.@(init)and globals #5136@(init)order #5146 (This issue is blocking Add native lock-free dynamic heap allocator #4749.)inits in system-dependent order #5174@(init)tracking issue #5352@(default_context)andintrinsics.__default_context#5296 (created as a resolution to Can't control allocator used in procs tagged with@(init)and globals #5136 but ran into its own platform-specific issues)I propose to strike
@init,@fini, and non-constant global variable initializers from the language.Specifically, a non-constant global variable initializer is anything of a form which requires runtime resolution to determine its value.
In place of all of the above, I propose the following paradigm which should be no stranger to any C programmer:
Not only will this hand over all control back to the programmer as to specifically how they handle their
contextand allocators thereof (fixing #5136 and completely negating the need for my PR #5296, a win for simplicity), it will make the precise execution order explicit and in the hands of the programmer, as is a keystone of the Odin programming language.From then on, any API which requires initialization must produce an
init_*procedure in its package which would do what is needed for it to function correctly.In the end,
@initand others only serve to magically hoist certain specified logic into_startup_runtimeand_cleanup_runtimewhich could be done just as well in the entry point by the programmer without all the extra complexity and sugar.@gingerBill @karl-zylinski @Kelimion
Beta Was this translation helpful? Give feedback.
All reactions