# Module-level fields are here! - Haxe - The Cross-platform Toolkit

**URL:** https://community.haxe.org/t/module-level-fields-are-here-haxe-the-cross-platform-toolkit/2475
**Category:** Announcements
**Tags:** blog
**Created:** [May 26, 2020, 7:25pm UTC](https://community.haxe.org/t/module-level-fields-are-here-haxe-the-cross-platform-toolkit/2475 "2020-05-26T19:25:21Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![mark.knol](https://community.haxe.org/user_avatar/community.haxe.org/mark.knol/32/50_2.png) [@mark.knol](https://community.haxe.org/u/mark.knol)
#### Post date: [May 26, 2020, 7:25pm UTC](https://community.haxe.org/t/module-level-fields-are-here-haxe-the-cross-platform-toolkit/2475/1 "2020-05-26T19:25:21Z")

</div>

Read more on our blog:

> **[Module-level fields are here! - Haxe - The Cross-platform Toolkit](https://haxe.org/blog/module-level-fields/)**
>
> It is now possible to define functions and variables directly in Haxe modules

---

<div class="post-metadata">

### Author: ![uvtc](https://community.haxe.org/user_avatar/community.haxe.org/uvtc/32/1198_2.png) [@uvtc](https://community.haxe.org/u/uvtc)
#### Post date: [May 26, 2020, 7:56pm UTC](https://community.haxe.org/t/module-level-fields-are-here-haxe-the-cross-platform-toolkit/2475/2 "2020-05-26T19:56:16Z")

</div>

Wow! This is awesome, and also seems like a big deal. 🙂 I remember when I first saw Haxe hello-world with everything in classes and reflexively thought, “oh, like Java”.

Would be great to showcase module-level fields in the “A Taste of Haxe” code block on the front page of \<[haxe.org](http://haxe.org)\>.

---

<div class="post-metadata">

### Author: ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)
#### Post date: [May 26, 2020, 8:09pm UTC](https://community.haxe.org/t/module-level-fields-are-here-haxe-the-cross-platform-toolkit/2475/3 "2020-05-26T20:09:30Z")

</div>

@uvtc I think that will have to wait until Haxe 4.2 is officially released, but yes, agreed.

---

<div class="post-metadata">

### Author: ![basro](https://community.haxe.org/user_avatar/community.haxe.org/basro/32/738_2.png) [@basro](https://community.haxe.org/u/basro)
#### Post date: [May 26, 2020, 8:38pm UTC](https://community.haxe.org/t/module-level-fields-are-here-haxe-the-cross-platform-toolkit/2475/4 "2020-05-26T20:38:46Z")

</div>

Are there any plans for module level variables?

---

<div class="post-metadata">

### Author: ![uvtc](https://community.haxe.org/user_avatar/community.haxe.org/uvtc/32/1198_2.png) [@uvtc](https://community.haxe.org/u/uvtc)
#### Post date: [May 26, 2020, 9:03pm UTC](https://community.haxe.org/t/module-level-fields-are-here-haxe-the-cross-platform-toolkit/2475/5 "2020-05-26T21:03:15Z")

</div>

Oh, the example there shows a `final`, but not a `var`. I assume that module-level vars are supported as well (since “fields” means both functions _and_ variables).

---

<div class="post-metadata">

### Author: ![basro](https://community.haxe.org/user_avatar/community.haxe.org/basro/32/738_2.png) [@basro](https://community.haxe.org/u/basro)
#### Post date: [May 26, 2020, 9:26pm UTC](https://community.haxe.org/t/module-level-fields-are-here-haxe-the-cross-platform-toolkit/2475/6 "2020-05-26T21:26:46Z")

</div>

Oops, somewhy my brain replaced ‘fields’ with ‘functions’ while reading and I didn’t even notice the final there.

I’m really happy about this feature 🙂

---

<div class="post-metadata">

### Author: ![Zhan](https://community.haxe.org/user_avatar/community.haxe.org/zhan/32/468_2.png) [@Zhan](https://community.haxe.org/u/Zhan)
#### Post date: [May 29, 2020, 5:58am UTC](https://community.haxe.org/t/module-level-fields-are-here-haxe-the-cross-platform-toolkit/2475/7 "2020-05-29T05:58:54Z")

</div>

it’s would be better if support inline for main()

inline function main()

---

<div class="post-metadata">

### Author: ![Gama11](https://community.haxe.org/user_avatar/community.haxe.org/gama11/32/7_2.png) [@Gama11](https://community.haxe.org/u/Gama11)
#### Post date: [May 29, 2020, 6:36am UTC](https://community.haxe.org/t/module-level-fields-are-here-haxe-the-cross-platform-toolkit/2475/8 "2020-05-29T06:36:47Z")

</div>

@Zhan I’m not really sure what the point of that would be.

---

<div class="post-metadata">

### Author: ![Zhan](https://community.haxe.org/user_avatar/community.haxe.org/zhan/32/468_2.png) [@Zhan](https://community.haxe.org/u/Zhan)
#### Post date: [May 29, 2020, 7:02am UTC](https://community.haxe.org/t/module-level-fields-are-here-haxe-the-cross-platform-toolkit/2475/9 "2020-05-29T07:02:07Z")

</div>

```
import global.cc.Component;

import global.cc.Label;

var label:Label;

var text:String;

function onPreLoad() {

    trace('onpreload');

}

function onLoad() {

    trace(js.Lib.nativeThis);

    label = cast js.Lib.nativeThis.label;

    text = cast js.Lib.nativeThis.text;

    label.string = text;

}

function update() {}

function onDisable() {}

function main() {// I hope support inline here

    global.Cc.Class({

        name: "fuck",

        'extends': Component,

        properties: {

            label: {

                'default': null,

                type: Label

            },

            // defaults, set visually when attaching this script to the Canvas

            text: text

        },

        onLoad: onLoad,

        update: update,

        onDisable: onDisable

    });

}

```

and target js is

function Main\_main() {

```
    cc.Class({ name : "fuck", "extends" : cc.Component, properties : { label : Main_label, text : Main_text}, onLoad : Main_onLoad, update : Main_update, onDisable : Main_onDisable});

}

```

and what I want is only

```
cc.Class({ name : "fuck", "extends" : cc.Component, properties : { label : Main_label, text : Main_text}, onLoad : Main_onLoad, update : Main_update, onDisable : Main_onDisable});

```

instead of

function Main\_main() {

```
    cc.Class({ name : "fuck", "extends" : cc.Component, properties : { label : Main_label, text : Main_text}, onLoad : Main_onLoad, update : Main_update, onDisable : Main_onDisable});

}

```

//BTW, how to get “this” keyword of module?
