12/11/2017 - 2:20 PM


This occurs when the last expression within a function is a call to another function. The outer function's return value becomes the inner function' s return value. This allows for more efficiency when writing code.

# Examples
sub log_and_greet_person {
  my $name = shift;
  log("Greeting $name");
  # This is a tailcall optimization
  return greet_person ($name); # returning from greet_person directly to the caller of log_and_greet_person
  # as opposed to, returning to log_and_greet_person() and then from log_and_greet_person().