book icon indicating copy to clipboard operation
book copied to clipboard

Wasm Game Of Life code examples are confusing

Open walston opened this issue 4 years ago • 1 comments

all of the code examples have poor indentation and give poor hints at where to place the code. Thru trial and error I think i've figured it out, but it would probably be better to comment the code examples with the filename at the top.

e.g.

// ... add to bottom of src/lib.rs
#![allow(unused_variables)]
fn main() {
  #[wasm_bindgen]
  #[repr(u8)]
  #[derive(Clone, Copy, Debug, PartialEq, Eq)]
  pub enum Cell {
    Dead = 0,
    Alive = 1,
  }
}

it also seems to be (from trial and error) that these things don't belong in fn main() and also the #![...] is an internal macro and therefore doesn't work outside of fn main() anyway.

walston avatar Feb 21 '20 01:02 walston

Agreed.

On "4.8 Time Profiling", I've not been able to get the "Time Each Universe::tick with console.time and console.timeEnd" piece working. Everything compiles and runs ok, but the console logging output is unchanged. :frowning_face:

Am kind of thinking it'd be useful to have a snapshot of the "complete & working" code for each of the sections (at that point in time) easily available, so people can investigate where they've gone wrong. eg probably in the GitHub repo or similar :wink:

While in my case it's likely (hopefully) something simple, I've spent a bunch of time on this without success and there doesn't look to be any path forward. :man_facepalming:

justinclift avatar Mar 02 '20 15:03 justinclift