#Can I import a set of functions from a struct/module into the global namespace?

1 messages · Page 1 of 1 (latest)

subtle inlet
#

usingnamespace?

marble comet
#

Yes but you can't use them without qualification though, i.e. @This().myfun

subtle inlet
#

I basically want to do something like how rust lets you import a set of methods into the global namespace with use mod::*

marble comet
#

I don't think there's a way to import everything like that, you would have to import them decl by decl unfortunately.

subtle inlet
#

Figured!

#

I'm reaching at straws too haha.

marble comet
#

If it's about ease of typing maybe give it a short name?

const a = @import("...")

Doesn't look very nice or clear though, using single letter identifiers like that.

#

Or maybe if you want some kind of global namespace you could usingnamespace a bunch into a n inner namespace:

const g = {
    pub usingnamespace @import("a");
    pub usingnamespace @import("b");
};