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

Compile time varargs of mixed types #40

Open
Victorious3 opened this issue Nov 17, 2023 · 0 comments
Open

Compile time varargs of mixed types #40

Victorious3 opened this issue Nov 17, 2023 · 0 comments
Milestone

Comments

@Victorious3
Copy link
Contributor

Right now there are two forms of varargs:

def varargs(...)
def varargs(a: int...)

The first one just exists for C interop and the second one creates an array. It is possible to accept any type with the second variant by using a void reference but the issue with that is that it's purely a runtime thing and you need to inspect the runtime type of your arguments.

def varargs(a: type...)

This could be the third variant which basically passes a tuple of the types which can be examined at compile time.
Doing so could be done like this:

def varargs(a: type...) {
    #if a.length == 1 {
        const first = a[0]
        type F = type_of a[0]
        ...
    }
}
@Victorious3 Victorious3 added this to the 0.5 milestone Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant