in reply to Templating and Programmatic Block Manipulation in Perl

Behavior re-use in Perl is most often handled as it is in other languages that don't have eval: with object inheritance and with pluggable designs (passing coderefs for variant behavior). The advantage to avoiding eval is that all code is compiled at compile time. No need for lisp's degree of introspection.

-- Randal L. Schwartz, Perl hacker

  • Comment on Re: Templating and Programmatic Block Manipulation in Perl

Replies are listed 'Best First'.
RE: Re: Templating and Programmatic Block Manipulation in Perl
by princepawn (Parson) on Sep 28, 2000 at 18:03 UTC

    Aha!

    I thought about your comments above. And I have a prototype for how it works.
    package HostCycle; $ftp_host = undef; sub until { ; } sub then { ; } sub cycle {my $self=shift; for $ftp_host (@ftp_host) { my $retval = $self->until($ftp_host); if ($retval) { $self->then($ftp_host); } else { ++$error_count; } package SendOrder; @ISA=qw(HostCycle); sub until { # Wait for upfile to disappear } sub then { # Upload orderfile and upfile } package GetOrder @ISA=qw(HostCycle}; sub until { # Wait for downfile to disappear } sub then { # Download all files in directory }

    And of course regarding runtime alteration of code blocks: when was the last time you needed that? Answer: when you are trying to create your model as metaphorical to the language as opposed to creating a model with the language. Douglas Hofstadter in "Goedel, Escher, Bach: The Eternal Golden Braid" tried to say that we needed self-modifying, self-reflective languages. But in actually we just need to ability to modify and study structures.