This is a simple question, but I'm curious about the "right" way to line-wrap curried functions in Scala. For example, suppose I have the moderately long line (if it's not long enough, you can pretend there are more parameters):

  def executeFooBarCommand(ce: CommandExecutor)(implicit ec: ExecutionContext): Future[FooBar] = {
    //...
  }


I have two problems regarding wrapping the long definition:

First, I'm not sure what the accepted best practice is for wrapping such lines (or even longer ones.

Second, most reasonable ways of wrapping the line seem to result and in "auto-rejoin" of the wrapped lines when I format in eclipse. I set eclipse never to join wrapped lines in java, and there doesn't seem to be a relevant setting in the scala IDE formatting section that I can find, so I'm not sure how to prevent the format command from joining these wrapped lines.


Question: Confused with HoldForm in Postfix notation
Answer: To be more specific, the difference is not because of the postfix application but because of the pure function (the part with # and &amp;) application:

Table[With[{x = i^k}, HoldForm[x]], {k, 1, 5}] (* no pure function *)
(* ==&gt; {i, i^2, i^3, i^4, i^5} *)

With[{x = i^k}, HoldForm[x]] // (Table[#, {k, 1, 5}] &amp;)  (* postfix pure function *)
(* ==&gt; {i^k, i^k, i^k, i^k, i^k} *)

(Table[#, {k, 1, 5}] &amp;) @ With[{x = i^k}, HoldForm[x]]  (* prefix pure function *)
(* ==&gt; {i^k, i^k, i^k, i^k, i^k} *)


Accordingly, if you simplify your example, and put some Prints in it:

Block[{k = 1}, Print[2]; With[{x = k}, Print[1]; HoldForm@x]]



During evaluation of In[17]:= 2
During evaluation of In[17]:= 1
(* ==&gt; 1 *)



Block[{k = 1}, Print[2]; #] &amp;@With[{x = k}, Print[1]; HoldForm@x]



During evaluation of In[17]:= 1
During evaluation of In[17]:= 2
(* ==&gt; k *)



As you can see, in the last case, the With is evaluated first, not Block, resulting in thus a replacement x -&gt; k, so Block cannot replace x in the second step as there is no x anymore in the expression.

An even more simple example that shows the reversed evaluation sequence for pure function application compared to normal, nested expression evaluation:

(Print[2]; Print[1];) 



2
1



(Print[2]; #;) &amp; @ Print[1]; (* or:  Print[1]; // (Print[2]; #;) &amp; *)



1
2