Skip to content

Infer type arguments based on the return type #43

@Victorious3

Description

@Victorious3

This is specifically to address the need for having to call:

var m: &Map(Str, int)
m = map::make(Str, int)

The information is already baked into the return type so it might be possible to infer it using this syntax:

def make -> &Map(type K, type V) {
    // use K and V here
}

m = map::make()

You could also do fancy things like overloading based on the return type:

def function -> type T {
    #if T == int {
        return 20
    } else if T == Str {
        return "Some string"
    } else {
        ...
    }
}

This does make overload resultion harder but it should be possible to implement by using a context type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions