The New Language Flux is Moving In!
Ownership and tracking of moving memory is important to many programmers, especially in environments where memory leaks are unacceptable…
The New Language Flux is Moving In!
Ownership and tracking of moving memory is important to many programmers, especially in environments where memory leaks are unacceptable. Life on the stack is easy, organized, and fast with free garbage collection, but the heap gets messy faster. Knowing memory has fully moved and all previous references invalidated is important to guaranteeing one does not access garbage memory values.
The tie operator ~ fixes this, instructing the compiler to follow a few simple rules.
1. A tied value requires it to be untied when used.
2. A tied value can only move to a tied type
3. One-time use, old reference invalidated when used
Example 1:
def foo(~int z) -> void // accepts a tied type
{
return;
};
def main() -> int
{
~int x; // Read as "tied int x
foo(~x); // Untie from main, tie to foo(), legal
x += 5; // Use After Untie (UAU) or "wow" error.
return 0;
};

After untying x from main, it is no longer a valid symbol at compile time. You must re-declare x as a new variable and allocate new memory.
Example 2:
def foo(~int z) -> void
{
return;
};
def main() -> int
{
~int x, y; // Tied vars
int z; // Non-tied var
foo(z); // Compile error, foo expects tied param
foo(~z); // Legal, invalidates z in main()
return 0;
};

Above we see an example of the separation of tied and non-tied types. You must pass z as ~z to invalidate z in main and satisfy the function signature.
Example 3:
def bar(~int y) -> ~int
{
return ~y;
};
def main() -> int
{
~int x, y;
int z;
z = bar(~y); // Copmile error, function returns tied type to non-tied type
x = bar(~y); // Legal, x is a tied type
return 0;
};

The final separation, z simply cannot accept a return value from bar() because z's type is non-tied, and cannot accept the explicit move.
Example 4:
def bar(~int y) -> ~int
{
return ~y;
};
def main() -> int
{
~int x, y, z;
int w = 5;
x = bar(~y);
z = w; // Illegal, must explicitly transfer with ~w
return 0;
};

Example 5:
def bar(~int y) -> ~int
{
return ~y;
};
def main() -> int
{
~int x, y, z;
int w = 5;
x = bar(~y);
z = ~w;
w = 10; // Compile error, w invalidated, must redeclare
return 0;
};

You can get Flux on GitHub and try it yourself!
메타데이터
- post_id
- 9d3bfadef5d3
- slug
- flux-is-moving-in-9d3bfadef5d3
- url
- https://medium.com/@karacvonthweatt/flux-is-moving-in-9d3bfadef5d3
- canonical_url
- https://medium.com/@karacvonthweatt/flux-is-moving-in-9d3bfadef5d3
- author_url
- https://medium.com/@karacvonthweatt
- status
- ok
- fetched_at
- 2026-06-09 14:34:10