Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

chromatic (983)

chromatic
  (email not shown publicly)
http://wgz.org/chromatic/

Blog Information [technorati.com] Profile for chr0matic [technorati.com]

Journal of chromatic (983)

Friday May 09, 2008
09:24 PM

Doing Nothing Better in Perl 5

[ #36374 ]

Perl 6 has three code placeholder operators, known affectionately as the "yada, yada, yada" operator (see List Prefix Precedence in Synopsis 3). It's a matter of (very sarcastic) public record how much I love writing, maintaining, and patching parsers, so I've just sent a very preliminary five-line patch to p5p to add support for ... to Perl 5.

--- perly.y~    2008-05-09 17:47:35.000000000 -0700
+++ perly.y    2008-05-09 17:47:41.000000000 -0700
@@ -1227,6 +1227,11 @@
             }
     |    WORD
     |    listop
+    |    DOTDOT
+            {
+              $$ = newUNOP(OP_DIE, 0,
+                  newSVOP(OP_CONST, 0, newSVpvs("Unimplemented")))
+            }
     ;

/* "my" declarations, with optional attributes */

Apply this to recentish bleadperl sources, run perl regen_perly.pl, rebuild, and now you can run programs such as:

sub foo { ... }
foo();

And get an "Unimplemented at file line line." error message.

(Now everyone who complains that I don't code enough to match my talk, please punch yourself in the face.)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Damn, you beat me to doing that. (That's good for my spare time!) I was expecting the ... part to be reasonably straightforward since it's reasonably similar to what the sub stub does already, but I've been putting this off because of ??? and !!!. But maybe I'm wrong and those just need something really similar?

    P.S.: I have been enjoying your blog posts much more since you switched from discussion of stuff to discussion of code. Please keep going.
    • ??? and !!! are similar to each other, because they rewrite into the die opcode, and that can happen in the lexer. The only problem is, as Ben Morrow pointed out, the lexer can rewrite the ??? of ??? : 1 : 0;, which is a mistake. Of course, it's also a horrible bit of code, and it's fixable with ?? ? : 1 : 0.

  • Shouldn't ... be DOTDOTDOT?