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

This is very cool, though I personally find postfix flow control confusing to read. The postfix loop with destructuring is especially odd to me. As I read left to right, I see variables that don't exist "yet" until I get to the later loop clause.

This is probably just a familiarity thing and I would get used to it, but compared to all of the other changes in the video which I think are pretty clean that stood out to me as a bit... iffy?



Agreed. I think there's a bit of LOC-golfing at work here. That loop is more nicely written as:

    for {handler, context} in @events[topic]
      handler.apply context, args


I agree. I also find unless statements to be difficult to read. I use this pattern all of the time in my JavaScript:

  if(!foo) {
    maybeDoSomething();

    return;
  }

  bar();
This lets me early exit, if needed, while letting the meat of the function not suffer from unnecessary indentation.

The unless statement makes the early exit seem like the default action rather than the exceptional action it (hopefully) is.




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

Search: