Anorectal function encompasses the complex coordination between the rectum and anal sphincters to control defecation and maintain continence. It involves sensory, motor, and reflex mechanisms that allow for the discrimination between solid, liquid, and gas, and the appropriate timing of defecation.