develooper Front page | perl.perl5.porters | Postings from June 2001

Re: the "it" hack

Thread Previous | Thread Next
From:
Tels
Date:
June 11, 2001 10:13
Subject:
Re: the "it" hack
Message ID:
200106101225.IAA6013529@www08.hway.net
-----BEGIN PGP SIGNED MESSAGE-----

Moin,

>On Sun, Jun 10, 2001 at 12:01:06PM +0200, Tels wrote:
>> >Do you want to explain what's going on everytime someone's used "sub it"
>> >and wonders why their program is now broken, then?
>> 
>> Error messages? Warnings?
>
>You've missed the point; this breaks old code.

Yes, yes, I know. ;o) Sometimes I wonder how _any_ new features were
introduced ever, because nearly all of them break some old code. But thats
OT. ;)

>> If your code is so obsfuscated as to have sub routine names with less
>> than 3 chars, you get what you deserve ;) [0]
> 
>Heh. No, that's not how we work.

>>         use it;
>>         while (<>)
>>           { 
>>           lc it and print it and next if $_ =~ /[A-Z]/;
>>           # do something else
>>           }
>
>use Filter::Simple => sub {s/\bit\b/\$_/g};
>No core hack required.

Well, my example was just me trying very hard to find a use for "it". Which
just shows that I do not need it (since $_ does the same).

>But anyway, we already have $_, so that's a bit of a waste of time.

>Furthermore that's not even what this patch does; it only sets "it" for
>"exists" and "defined" - and even then, only on array and hash elements
>- which is of even more dubious utility. 

Oh, missed that. I thought it would set it to the last expression's
result like:

        $a = 8 * 9; $c = it + 4; return it if it+3 > 6;

Not that I think thats really needed. Just as I said, I can not come up
with nifty, cool, sexy or other usefull examples of "it".

>And as Graham's noticed, that
>leads to scoping worries. For one point, what should this do:
>
>    {
>        my %foo = (1=>30);
>        exists $foo{1};
>    }
>    print it;
>
>For twenty more points, why?

No idea, really.

>It's a fundamentally broken idea, and it's a big shame people are pursuing
>this as anything other than a learning exercise when there's useful things
>that could be done.

Well, if people would sensible all the time, the world would be boring.[0]

Best regards,

Te"must forget it - must forget it - must forget ...what?"ls

PS: I know about the email. It usually works, but I am currently moving my
domains around, switching provider etc and my "exception" rule for that
spam trap address has fallen over the edge. Sorry. Should work in 5 minutes
again.

[0] And without Perl, Linux, Yoghurt, bikes and a couple of
other things I would miss.

- -- 
perl -MMath::String -e 'print \
Math::String->from_number("+215960156869840440586892398248"),"\n"'

 http://bloodgate.com/thief/     Thief - The Dark Project
 http://bloodgate.com/perl       My current Perl projects
 http://freedomforlinks.de       Fight for your right to link. 
 PGP key available on http://bloodgate.com/tels.asc or via email.


-----BEGIN PGP SIGNATURE-----
Version: 2.6.3i
Charset: latin1

iQEVAwUBOyNmmHcLPEOTuEwVAQHNBgf+OuvgSzkqaA30BqeUg2cCB7A0kyzOBSCa
rVywVQUIJCas19eqPrDsbQch2JlYfbUIB4pBS99ycbL15no+th6l5pVcfOnTZPmE
xePK41hu9H4WnNrfI+07enjZeJfoNXJQkixN7jmmnpGQtTyVN8xO1D3+bO68Fxwv
+KVIS7HcsRQnSOhIhvggsv5DwbY867dCGcJJZ51/Wyjv+eS+duv3qtwgSlIN9ZSY
LszGf3vVno1CuYIGosXLyZLJPT0qQT/Lep2CezozqMqWARFI/1UChq2ASAtV18Ae
/siOdA5haCcecIgr4pDmidCuqFVpaSmfSuzaP/DOh6x1gC7vPPKKiw==
=tLCj
-----END PGP SIGNATURE-----

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About