Odin»Forums
7 posts
Import packages without a namespace?

Hi, I downloaded Odin for the first time a few hours ago, and got to do some experiments. I really like the language, but I find it really annoying that every import is always put in a separate namespace, and that you can't put a using statement at global scope.

For example, I tried to write a simple win32 app, but when I got to the window callback:

package main
import "core:sys/windows"

...

window_callback :: proc(window: HWND, message_kind: UINT,
                        wparam: WPARAM, lparam: LPARAM)
                       -> (result: LRESULT) {
...

I got errors for undefined types HWND, UINT, WPARAM etc.. Now, for the procedure I can say using windows, but I can't find a convenient way to do that for the arguments. I could do this:

HWND :: windows.HWND;
UINT :: windows.UINT;
...

But if I have to do that for every type I want to pass around It's going to get old really quickly. Is there a way to reference imported things without having to say the package name every time? I know that one of the language goals is to be explicit, but I find this a bit too much...

Simon Anciaux
1337 posts
Import packages without a namespace?

You'd probably get faster help on the Odin discord: https://odin-lang.org/community/

7 posts
Import packages without a namespace?

Oh ok, thank you.