这是indexloc提供的服务,不要输入任何密码
Skip to content

Function overloading #876

@litherum

Description

@litherum

WGSL already has multiple overloads for functions - we have vec4<f32>(f32, f32, f32, f32) and vec4<f32>(vec2<f32>, vec2<f32>) (among many others). Given that the compiler will already have to have overload resolution support to make vector constructors work, there's no reason why it should be forbidden for author-created functions.

Implementation is pretty easy because we don't have inheritance or generic types right now - we just have a sea of flat types. So the overload resolution would just be "find the overload that has the right number of parameters and the parameter types match the types of the arguments."

Entry points should be required to have unique names so they can be identified uniquely without writing a whole signature (or having to generate mangled names like C++).

Metadata

Metadata

Assignees

No one assigned

    Labels

    wgslWebGPU Shading Language Issues

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions