Skip to content

Add typed arguments to functions  #2

@aceinetx

Description

@aceinetx

Take for example this function:

fn add a b {
return a+b;
}

We can pass literally anything to it, and that's a problem

We can implement type hints like this:

fn add a: num b: num {
return a + b;
}

The function call will error out if the arguments don't match the expected types

We can also take advantage of a special dictionary field called '_typename'. Then we can also pass a Result struct to something:

fn do_smth x: Result {
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions