On Saturday, June 23rd,
Damian Conway
had a little free for all free-for-all workshop that
he gave at
College of DuPage in Wheaton, IL.
He talked about a ton of different Perl topics, all of
them enlightening.
He's a great speaker, and I wish I could have gone to the 3-day class that
he gave earlier in the week.
Here are some random notes of interestingness that
I scribbled down. Perhaps
frag will want to add some of his own comments.
- ``$/ tells when to stop reading''
We all know about the $/ variable, but a new light dawned when Damian said
``$/ tells when to stop reading''. That's why $/ = undef makes Perl read
an entire file: There's no definition of when to stop reading.
How clear it is now.
- Perl 6 may have the ... operator
Perl 6 may have the ..., which Damian pronounced as the ``yada yada yada operator.''
You'd use it as a placeholder for undefined code like so:
sub mangle {
...
return 1;
}
Yes, that's a literal ....
Executing mangle() would have Perl kick out a message like ``sub mangle is pending
future code''.
- Typeglobs
``Typeglobs are like a box of chocolates'', he said, and then explained why in a
way that let me finally understand the method behind the madness of typeglobs.
Of course, typeglobs are going away in Perl 6.
- Perl's phases
Big discussion of Perl's 5 phases: BEGIN, CHECK, INIT, execution and END, and
when you'd want to use which one.
- The benefits of golf
He didn't specifically explain that golf in the extreme
way we golf here is good,
but rather that
``The fewer characters you type, the fewer characters you can get wrong.''
He claims that there's a linear correlation between the number of characters
in a system's source code and how many bugs it has.
- Qualifiers, not control structures
In this code
foreach ( @foo ) {
whack($_);
}
the foreach is a control structure.
In this code:
whack($_) foreach @foo;
the foreach is a ``qualifier'', which is why you can't apply it to a block in
that syntax.
- Perl optimizes a lot
The Perl pseudocode has no ifs in it. Anywhere.
``How can that be?'' I asked. He then showed the following reduction:
if ( $x > 50 ) {
do_something();
}
is the same as
($x > 50) && do_something();
It's all just a lot of booleans in there.
- The use of the v notation
Version strings are tracked with the v notation, like v5.6.0, which gives
a string equivalent to chr(5).chr(6).chr(0). This is also handy for IP
addresses, as in v127.0.0.1.
- Attributes
Big discussion of attributes and the Attributes::* modules, most of which I didn't
note because I don't see any direct application for them in my work. However,
Perl 6 is going to make a LOT of use of attributes.
- Object-oriented design
He presented his Spinal Tap-style list of
Ten criteria for object-oriented design. This list
will eventually be part of the standard Perl distro.
- What's coming in Perl 6
Since Damian is sort of Larry's right hand man for language design issues, he's on
top of all the changes that are going to be coming. Some of my favorites:
And here is where my notes end. I wish I had a videotape
of it. He's just great.
xoxo,
Andy
--
I was dreaming when I wrote this, so sue me if I go too fast.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|
|