On Monday, May 23, 2016 18:10:02 Steven Schveighoffer via Digitalmars-d wrote: > On 5/23/16 5:47 PM, Ali Çehreli wrote: > > On 05/23/2016 01:27 PM, Steven Schveighoffer wrote: > >> On 5/23/16 4:01 PM, Andrei Alexandrescu wrote: > >>> So swap(a, b) swaps the contents of a and b. This could be easily > >>> generalized to multiple arguments such that swap(a1, a2, ..., an) > >>> arranges things such that a1 gets an, a2 gets a1, a3 gets a2, etc. I do > >>> know applications for three arguments. Thoughts? -- Andrei > >> > >> One thing that screams out to me: this should be called rotate, not swap. > > > > Yes, rotate(), but then I would never remember what direction it rotates. > > Use the law of UFCS: > > x.rotate(y, z); // x-> y, y -> z, z -> x
Hmmm. And I would have assumed that it rotated in the other direction. This is really going to need a very specific name like rotateLeft or rotateRight in order for it not to be error-prone. - Jonathan M Davis
