New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax for creating a symbol alias #420

andrewrk opened this Issue Aug 17, 2017 · 3 comments


None yet
2 participants

andrewrk commented Aug 17, 2017

Aliases, unlike function or variables, don’t create any new data. They are just a new symbol and metadata for an existing position.

@andrewrk andrewrk added this to the 0.2.0 milestone Aug 17, 2017

@andrewrk andrewrk changed the title from syntax for creating an alias to syntax for creating a symbol alias Aug 17, 2017


This comment has been minimized.


andrewrk commented Aug 18, 2017

Maybe we don't do this since you can pretty easily accomplish it with module level assembly (#256)


This comment has been minimized.


raulgrell commented Aug 20, 2017

I'm not sure if this is what you mean, but I'd really like a way to be able to refer to the elements of an array in a struct by another name (like with an anonymous union), where something like this would be valid:

const Vec2 = struct {
      data: [2]f32,
      alias x =[0]; // or: @alias(this, "x",[0])
      alias y =[1]; // or outside the struct: @alias(Vec2, "y",[0])

var vec = Vec2 { .data = []f32 { 0, 0} };
vec.x = 1;
vec.y = vec.x * 2;

This comment has been minimized.


andrewrk commented Aug 20, 2017

Now that we have packed structs you can do this:

const Vec2 = packed struct {
    x: f32,
    y: f32,

and memory layout is guaranteed to be exactly as you describe. That would solve your use case I believe.

As for this issue, it's referring to the ability for ELF files to have multiple symbols that point to the same address in virtual address space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment