Sitelet https://github.com/gpuweb/gpuweb/issues/1243
Skip to content

Consider whether to allow trailing commas #1243

Description

@Kangz

A common usability enhancement in programming languages is to allow trailing commas when defining data structures. This doesn't work in WGSL and the code below is invalid.

var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
  vec2<f32>(-1.0, -1.0),
  vec2<f32>( 1.0, -1.0),
  vec2<f32>(-1.0,  1.0),
);

Could we consider allowing trailing commas so that copy pasting lines like this works as expected and matches other languages? Having the function-like constructors might make this awkward though.

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

    wgslWebGPU Shading Language Issues

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions