introspection (and Perl 6)

David Cantrell david at cantrell.org.uk
Wed Jan 23 15:13:10 GMT 2008


On Tue, Jan 22, 2008 at 09:56:08AM -0500, Jeff Anderson wrote:
> On Jan 22, 2008 5:49 AM, Ovid <publiustemp-londonpm at yahoo.com> wrote:
> > In short, if people can't read the code I write, that's my fault.  If
> > they can't read the language I write in, that's their fault.

I take it that you consider yourself to be reasonably competent in perl
5?  Good, thought so.  Now, what does this do, and how does it work?

#:: ::-| ::-| .-. :||-:: 0-| .-| ::||-| .:|-. :||
open(Q,$0);while(<Q>){if(/^#(.*)$/){for(split('-',$1)){$q=0;for(split){s/\|
/:.:/xg;s/:/../g;$Q=$_?length:$_;$q+=$q?$Q:$Q*20;}print chr($q);}}}print"\n";
#.: ::||-| .||-| :|||-| ::||-| ||-:: :|||-| .:|

If it's not immediately obvious to you, well, that's your fault for
being incompetent in perl 5.

Yes, that's an obfuscated perl contest entry.  All it does is take the
idea that if it's legal perl syntax you should be able to read it, and
turn it up to 11.  I'm sure you can pick it slowly apart and figure it
out.  That, however, is not what you want to do when you're bug-fixing
my crappy code.

> I just don't understand the need to express HOW as the character ^,
> especially considering that ^ already had meaning in Perl.

The following operators are apparently defined which include the ^
character:

.^   <-- this is the one we're talking about
+^
~^
?^
^
+^
~^
?^
^
..^
^..
^..^
^^

Yes, the two plain ^ operators are different (not that that's a problem
- we already have - for both negation and subtraction).  Even so, having
that many different ^-ish operators does strike me as being at odds with
the idea that good code is easy to read.  I think I'm going to end up
grumbling as much about the ^ character in perl 6 code as I do about the
* and & characters in C.  They might make the code quicker to type and
more compact, but they do that at the expense of readability *even for
an experienced programmer in that language*.

And no, before any of the usual suspects emit their usual stupid bleats,
I'm not advocating COBOL.  I'm advocating a sensible compromise.  Saying
'HOW' would be a sensible compromise.  If I ever get to write a perl 6
coding guideline like I have done for perl 5 here at work, obfuscatory
chains of punctuation will be strongly deprecated.  Yes, I'll be
perfectly happy to say "no" to particular operators.  I already say "no"
to particular *keywords*.

As an aside, I also note that the range operator .. supports non-ASCII
character ranges.  I wonder which direction it will go if you use a
right-to-left language :-)  And if you're using Korean, do you have to
write it like this:

  [squiggle] : [squiggle]

or:

  [squiggle]
  .
  .
  [squiggle]

?

-- 
David Cantrell | London Perl Mongers Deputy Chief Heretic

         Nuke a disabled unborn gay baby whale for JESUS!


More information about the london.pm mailing list