Skip to content

Compile time varargs of mixed types #40

Description

@Victorious3

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]
        ...
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions