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

Defined parameters for specialization of polymorphic functions #23

Open
Victorious3 opened this issue Apr 2, 2023 · 0 comments
Open
Labels
proposal New feature or request

Comments

@Victorious3
Copy link
Contributor

When overloading a generic function that takes an argument of any type,
it is trivial to specialize it for a specific case by simply using that type for an argument:

def polymorph(a: type T) -> T {
    return a
}

def polymorph(a: int) -> int {
    return 20
}

However, for type parameters this is currently impossible.

It could look like this:

def polymporph(type T) -> int {
    return size_of T
}

def polymporph(int) -> int {
    return 20
}

Note that this doesn't conflict with default parameters, those would use an =

@Victorious3 Victorious3 added the proposal New feature or request label Apr 2, 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