feedback icon indicating copy to clipboard operation
feedback copied to clipboard

[your-first-webgpu-app] Reserved keyword `in` used in example code

Open beefchimi opened this issue 1 year ago • 1 comments

  • On the following page: https://codelabs.developers.google.com/your-first-webgpu-app#6
  • Under the following section: Use the ping-pong buffer pattern

You give an example of "ping-pong state" for the reader to try (but not to copy into the project). The reader may want to copy/paste this example in order to test it out, only to hit an execution error. This is because one of the arguments is named in, which is a reserved keyword.

My proposal:

function simulate(incoming = [], outgoing = []) {
  outgoing[0] = 0;

  for (let i = 1; i < incoming.length; ++i) {
     outgoing[i] = incoming[i-1];
  }
}

Additionally, there is a very minor issue on the previous page: https://codelabs.developers.google.com/your-first-webgpu-app#5

There appear to be some rogue * characters. If you search for Another alternative, you should find it:

Screenshot

error-1

beefchimi avatar Aug 02 '24 20:08 beefchimi

Thank you really much @beefchimi!

incoming = [], outgoing = [] would work. I also like inArray, outArray.

Thanks for catching the * characters issue as well!

I'll let you know when the codelab is updated.

beaufortfrancois avatar Aug 19 '24 09:08 beaufortfrancois

This issue is now fixed. See https://codelabs.developers.google.com/your-first-webgpu-app?hl=en#5 and https://codelabs.developers.google.com/your-first-webgpu-app?hl=en#6

beaufortfrancois avatar Aug 21 '24 07:08 beaufortfrancois