Skip to content
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

Infer type arguments based on the return type #43

Open
Victorious3 opened this issue Dec 7, 2023 · 0 comments
Open

Infer type arguments based on the return type #43

Victorious3 opened this issue Dec 7, 2023 · 0 comments
Labels
proposal New feature or request

Comments

@Victorious3
Copy link
Contributor

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.

@Victorious3 Victorious3 added the proposal New feature or request label Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant