Users of more civilized languages (such as INTERCAL) have advanced into making the programer be a little more polite in order to counteract unnecessary hubris. The compiler will make sure you are polite in your source code, and give a fatal error if you don't. But don't try to fool the compiler by giving faux politeness everywhere, or it will still fail to compile.

Because of the barbaric orgins of Perl, it lacks a please() function in the basic language. I hope to help rectify this in a future version, but until then you can use the please() function in this module. May it help you find your new identity as a civilized coder!

package Acme::Polite; no strict; # Strict isn't very polite no warnings; # Neither is warnings use Filter::Util::Call; use constant CEILING => 10; # Must be at least this polite use constant FLOOR => 3; # But not too polite sub import { my $pkg = shift; my $ref = []; filter_add( bless $ref => $pkg ); } sub filter { my $self = shift; my $status; while( ($status = filter_read) > 0 ) { # noop } my $source = $_; my $semi_count = () = $source =~ /(;)/g; my $please_count = () = $source =~ /(please)/g; my $politeness_rating = $semi_count / $please_count; if( $politeness_rating < FLOOR ) { die "You were too polite!\n"; } elsif( $politeness_rating > CEILING ) { die "You weren't polite enough!\n"; } return $status; } sub please { return @_ } 1; __END__

"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

Replies are listed 'Best First'.
Re: Be a More Polite Programmer
by diotalevi (Canon) on Oct 08, 2004 at 20:54 UTC

    I'd like this package to notice how many statements its caller has and to scale the politeness so that 30% to less than 100% politeness is acceptable. I'd also like to see this happen without source filters.

    Care to oblige?

      Configurable politeness values are something I thought about (it's easy as giving a parameter to import). I might make the modifications for it.

      Any ideas on how to do it without a source filter?

      "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

Re: Be a More Polite Programmer
by BrowserUk (Patriarch) on Oct 08, 2004 at 23:05 UTC

    Intriguing, but to whom is the programmer being polite?

    Does the advent of this inevitable technology mean that we can imminently expect the Ana Nova talking head to interupt her newscasts with

    "Excuse me, I'll be right back, but I have to go deal with my programmer who is currently being rude!"?

    :)


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon