The triple line
The Romans adopted this phalanx, which was originally Greek. Where a legionary stood in the battle order depended on their level of military seniority. The triple line consisted of the hastate, the principles, and the triarii. Surprisingly, the hastati, the least experienced guys, comprised the front rank. The principles and then the combat veterans, the triarii, were behind them. The unfortunate velites, the newest (and typically least skilled) recruits, stood in front of everyone. They would throw javelins at approaching foes before vanishing behind the triarii.
The line beyond which a Roman legionary would not retreat was the final rank, which might be some distance back. The phrase "falling on the Triarii" came to indicate engaging in a last-ditch battle.
The three lines would frequently create a mile-long battle configuration with alternating gaps, creating a broader but still seemingly unbroken fighting front. These spaces offered the already adaptable legion even more leeway, allowing the rear ranks to advance up into a threatened line.