Adam Kennedy wrote:

Forgive my ignorance here, but for all of these different ways of doing constants, will they all optimize (including partial evaluation/currying) at compile/build/init/run-time?


my $gravity is constant = 10; # One significant figure

sub time_to_ground ($height, $accel) {
    ...acceleration math...
}

my $time = time_to_ground( 500, $gravity );

... thus simplifying internally to

my $time = 1234;

No. But you could get the effect by explicitly asking for time_to_ground() to be called at compile-time:

  my $gravity is constant = 10; # One significant figure

  macro time_to_ground ($height, $accel) {
     ...acceleration math...
  }

  my $time = time_to_ground( 500, $gravity );

Damian

Reply via email to