Right now we declare globals using the type e.g. I32.global(name: 42) or F32.global(blah: 1.5)
What if instead we allowed module attributes to be the globals? This would let normal Elixir code read their values too, as we’d keep the attribute definitions. It would also match the current @some_global syntax to read a global in functions.
You can see that whether it is an integer or float is detected by from its Erlang type (is_integer(42) vs is_float(42.0))
In a future world with 64-bit numbers, they would be enabled using a parameter export_global :mutable, 64 do or a name like export_global64 :mutable do
Another alternative is Global.expose_attributes([:xn, :yn, :zn, :k, :e])
Right now we declare globals using the type e.g.
I32.global(name: 42)
orF32.global(blah: 1.5)
What if instead we allowed module attributes to be the globals? This would let normal Elixir code read their values too, as we’d keep the attribute definitions. It would also match the current
@some_global
syntax to read a global in functions.It could look like:
You can see that whether it is an integer or float is detected by from its Erlang type (
is_integer(42)
vsis_float(42.0)
)In a future world with 64-bit numbers, they would be enabled using a parameter
export_global :mutable, 64 do
or a name likeexport_global64 :mutable do
Another alternative is
Global.expose_attributes([:xn, :yn, :zn, :k, :e])