develooper Front page | perl.perl6.internals | Postings from August 2004

Re: Something to ponder

Thread Previous | Thread Next
Felix Gallo
August 18, 2004 12:57
Re: Something to ponder
Message ID:
Dan writes:
>     sub foo :come_from('+', int, int) {}

One problem with MMD in general, and return specifically, is
'what happens if multiple M match the same D requirements?

sub foo :come_from('+', int, int) { shift; shift builtin::+ shift };
sub bar :come_from('+', int, int) { shift; shift builtin::* shift };

If the answer is 'all get executed', this could be useful for
any languages interested in implementing aspect-oriented programming
as a first class language feature, e.g.

sub debug_log :come_from(:benchmark_me) { 
    my $function_name = shift;
    print STDERR "debug: $function_name at " . time() . "\n";

sub notify_with_pager :come_from(:notify_me) {

sub foo :benchmark_me { ... } # gets benchmarked
sub bar :benchmark_me :notify_with_pager { ... } # benched and notified
sub baz { ... } # not so much with the benchmarking

If the answer is 'the second match is a syntax error'...well,
that spoils the fun, but who said talking about continuations was
supposed to be fun?


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About