On Thu, 2002-04-04 at 10:39, Timothy Johnson wrote:
>  
> At the risk of beating a dead and bloated horse, I have no doubt that I will
> enjoy and take advantages of the improvements in Perl6, but I still don't
> see the logic in changing operators.  I mean, why make old code unusable?
> If you can make a Perl5->6 converter, why can't you integrate Perl5 code
> into Perl6?  Like I said, I have no doubt that I will use the many new
> features of Perl6 and enjoy them, but I think that sums up a lot of the gut
> reactions of people that I have spoken to.
> 
<snip />

Okay, on the walk into work this morning I thought of another reason why
the operators are changing: Huffman encoding.  The reason Perl looks
like line noise to many people is because the language tries to save the
programmer keystrokes for commonly used things.  With that in mind I
wrote a quick script and through all of the perl code in my home
directory at it to find out how often I use '->' vs '.' in Perl 5.  The
results came to about 7 to 1 in favor of '->'.  According to the rules
of Huffman encoding that means that '->' should be shorter than '.'. 
Add on to that the fact that '.' is used by most languages to mean
"member of" and you have a no-brainer.  Now, I use hash references like
water so YMMV.

<script>
#!/usr/bin/perl -ln

$arrow  += /->/g;
$period += /\./g;

END {
        print "arrows occured $arrow times";
        print "periods occured $period times";
}
</script>

<output>
arrows occured 1263 times
periods occured 173 times
</output>

-- 
Today is Setting Orange the 22nd day of Discord in the YOLD 3168
P'tang!

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to