News for hackers. Stuff that matters.
Re:Go Lang: Comments Are Not Directives by mpdehaan2 on Monday May 11, 2015 @02:14PM (#9526685)
Nesting them I feel is almost always bad

blarg = [ foo(x) for x in y if x > 2]

I think is pretty decent. Helps if they are calling named functions, so it's more self documenting, depending on complexity.

Dict comprehensions can be a little brain-warping too :)

Re:Go Lang: Comments Are Not Directives by kbenson on Monday May 11, 2015 @02:59PM (#9527060)
Yeah, the Perl equivalent of that is:

  my @blarg = map { foo($_) } grep { $_ > 2 } @y;
A bit more verbose, but if you know Perl, obvious (and the same building blocks allow for more powerful constructs[1], since they really are functional code blocks).

You can argue the Python version is clearer, but placement of the conditional always throws me off. I like to think of my transforms as a pipeline.

1: http://en.wikipedia.org/wiki/Schwartzian_transform