Skip to content

Unified Call Syntax #148

@jmi2k

Description

@jmi2k

You can see it here. I've seen it in some new languages, and I think it fits perfectly into Zig. Also, it allows adding functions that operate on any type after declaring all their members: just put it as the first argument.

glfwSetKeyCallback(window, key_callback);    // Meh
window.glfwSetKeyCallback(key_callback);     // Nice!

struct TwoNumbers {
    x: i32,
    y: i32,

    pub fn add() -> i32 {
        return x + y;
    }
}

// Simple and clean!
pub fn sub(self: TwoNumbers) -> i32 {
    return self.x - self.y;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingImplementing this issue could cause existing code to no longer compile or have different behavior.enhancementSolving this issue will likely involve adding new logic or components to the codebase.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions