On Sun, 14 Apr 2013 22:00:18 -0700 "H. S. Teoh" <hst...@quickfur.ath.cx> wrote:
> On Sun, Apr 14, 2013 at 11:46:04PM -0400, Nick Sabalausky wrote: > > I've never seen a big problem with the statement vs expression > > distinction, and I think the "statements == expresions" languages > > sometimes takes things slightly overboard in the process of forcing > > them into the same mold. However, I've *definitely* wished on many > > occasions that D's switch could be used as an expression like in > > Haxe. > > Allowing arbitrary predicates and switch-as-expression allows you to > write code that shows intent very clearly: > > // In pseudo-D syntax > void fill(T)(T image, int x, int y) { > image[x,y] = switch { > case isFillable(image,x,y): fillColor; > case isBorder(image,x,y): borderColor; > default: defaultColor; > }; > } > Yup, like I said, I've definitely wished that D's switch could be used as an expression