Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Contrarily:

Push ifs down:

  BAD:
    if (ptr) delete ptr;
  GOOD:
    delete ptr;
Polymorphize your fors:

  frobnicate (walrus);
  frobnicate (walruses) { for walrus in walruses frobnicate (walrus); }


I agrée with them and with you. It looks like they work in some poor language that doesn’t allow overloading. Their example of `frobnicate`ing an optional being bad made me think: why not both? `void frobnicate(Foo&); void frobnicate(std::optional<Foo>& foo) { if (foo.has_value()) { frobnicate(foo); } }`. Now you can frobnicate `Foo`s and optional ones!


Indeed they are working in a poor language that doesn't allow overloading. It's Rust. :-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: