The Other McCain

"One should either write ruthlessly what one believes to be the truth, or else shut up." — Arthur Koestler

Software Enhanced Politics: Perl Flip-Flop

Posted on | December 5, 2011 | 5 Comments

by Smitty

Coding is actually fun, not that I have time to do much anymore, because you can work on small problems and actually solve them. In politics, you talk about solving problems as though a closed-form solution was somehow obtainable. In the blog world, you can compare this site to a retail shopping trip to a department store. Your web browser is the sales associate, busily getting the shoes in hopes of a fit. The database is the store-room, with all the merchandise arranged to cram in the most stock, while still retaining easy access, if not best display. The internet and web server is all of the streets and traffic signals between your house and the parking lot, doing all of the utterly boring work of moving traffic along according to some relatively stable protocol, say HTTP.

The wildly dynamic work of getting just the right style of shoe in the right size and determining that the shoe fits, so that you can wear it, lands on the scripting engine. This particular blog is composed in WordPress, which is to the PHP language what Legalese is to English: sure, WordPress is PHP, but brings enough specialization to the task that you can’t just buy a PHP cookbook and expect to get very far with the WordPress codebase.

Who cares about these details? You wanted a blog post, not a meditation on coding. If all of the infrastructure works, you get the post, and the tools involved fade like presidential campaigns long since suspended. It matters not if the blogging tool is implemented in PHP, the relatively clean looking Python, or the quirky, idiomatic Perl.

Now and then, though, you get some reflection of software programs into political programs, of geek code into legal code, of information state into nation-state. This happened when I saw a post on the Perl ‘flip-flop’ operator. In electronics, you have the concept of the bi-stable multivibrator, which is far less kinky than it sounds. It’s essentially an electronic light switch, flipping on, or flopping off based upon an input, but, most importantly, staying that way, like an unprincipled politician awaiting the next lobbyist to flash some cast and adjust a vote.

Perl’s gift to software is to have more operators than the Democrat Party. So many, in fact, that some joker arranged them as a periodic table. Perl really fetishes operators, having around an order of magnitude more than most other languages with which you’d care to tangle. The subject of the post is the flip-flop operator, which has massive political application.

Perl 5 has a binary operator called flip-flop that is false until its first argument evaluates to true and it stays true (flips) until the second argument evaluates to true at which point it becomes false again (flops). This is such a useful operator that Perl 6 also has flip-flop, only it’s spelled ff and has a few variants:

ff
ff^
^ff
^ff^

The circumflex means to skip the end point on that end.
Perhaps some examples are in order …

for 1..20 { .say if $_ == 9 ff $_ == 13; }
# 9 10 11 12 13

for 1..20 { .say if $_ == 9 ff^ $_ == 13; }
# 9 10 11 12

for 1..20 { .say if $_ == 9 ^ff $_ == 13; }
# 10 11 12 13

for 1..20 { .say if $_ == 9 ^ff^ $_ == 13; }
# 10 11 12

As with a political tool, the software tool should provide maximum capacity to obscure meaning. This blog holds forth the hope that proper grasping of the nuances of the flip-flop operator will lead to greater dexterity in the assumption of positions which candidates have previously opposed. For example, usage of the flip-flop operator can allow simultaneous treatment of terrorism as a law enforcement issue on the one hand, while employing armed drones to atomize terrorists on the other, even if the terrorists are U.S. citizens, without the sordid embarrassment of a software crash. A physical light switch operated at modern political frequencies would shatter like a teleprompter falling to the cold, hard, real ground. The ephemeral nature of software brings to politician to that nirvana-like state of being able to hold two positions simultaneously. If the flip-flop operator were any more powerful, they should have to call it the Progress operator.

Bookmark and Share

Comments

  • http://www.pelosi.house.gov/ Nancy Pelosi

    This happened when I saw a post on the Perl ‘flip-flop’ operator. In electronics, you have the concept of the bi-stable multivibrator, which is far less kinky than it sounds. It’s essentially an electronic light switch, flipping on, or flopping off based upon an input, but, most importantly, staying that way, like an unprincipled politician awaiting the next lobbyist to flash some cast and adjust a vote.

    These are quite common and sold everywhere in San Francisco.  I am proud of that. 

    Palamino!

  • http://twitter.com/perlpilot perlpilot

    Wow.  Just wow.

  • Mortimer Snerd

    That operator is Mitt Romney’s favorite!

  • NAME REDACTED

    for $smallcash ..$bigcash (.say if $_ != $environmentalism Gingrich $_ =$immigration; }

  • Anonymous

    I’ve heard tell that Mrs. Smitty likes it when you GeekSpeek.  Sending WYB to Grandma’s tonight, eh? (wink)