That was not an inconsistent behavior of peach and each.
First, Functions in kdb has implicit parameters as x,y,z if not specified any.
So f:{x+y} is equivalent to f:{[x;y] x+y}
But f:{[a;b] a+b} will not have x,y,z as implicit parameter
For more details, see section Implicit Parameters in http://code.kx.com/q4m3/6_Functions/#617-implicit-parameters
Peach Case: When you do {(raze x), (raze y)} peach x :
i) Another way of writing this function is:
f:{[x;y] (raze x),(raze y)}
And call is like: f[;] peach x
So you are passing global x to local x of a function but nothing in y, that's why you are getting only 1 and 2 and not 3 &4 in output.
ii) Why only 1 and 2 and not a
b!1 2 in output?
When you pass each row of table (x in your case) to a function, it goes in form of a dictionary. And raze on dictionary gives only values.
You have to modify your function for correct working like this(Use Each Both ):
flip {x,y}' [x;y]
' is each both which is used when you have more then one arguments and you want to apply each on all of them simultaneoulsy.
This will take one row at a time from both global x and y and copy it to local x and y in dictionary form and then join them.
Each Case:
Each is just giving you message that your function requires 2 arguments and hence it couldn't execute it.
Why Peach worked and Each didn't?
Peach and Each are not same for some scenarios. When you have dyadic function, then peach works like each prior(':) and not as Each. They are same only for monadic functions. In your case you have dyadic function.