develooper Front page | perl.perl5.porters | Postings from September 2003

RE: [perl #23754] Possible bug?; keywords for sub idenifier?

Thread Previous
From:
Brent Dax
Date:
September 7, 2003 15:23
Subject:
RE: [perl #23754] Possible bug?; keywords for sub idenifier?
Message ID:
005201c3758e$9b88de70$2a01a8c0@brent
sr@blz.hmrprint.com (via RT):
# I just wondering, why does Perl allow you to use supposedly reserved
words
# for a sub (function) identifier?

This is a feature, not a bug.

Perl allows you to use reserved words as identifiers because there's no
good reason *not* to.  Remember, you can call a function with an
ampersand (&), so it's not like there's no way to access a function with
the same name as a reserved word.

Moreover, it's good for backwards compatibility.  How many programs had
functions called lock() before we added threads (and thus locks) to
Perl?  People weren't forced to rewrite those programs *because* Perl
allows functions to have the same names as built-ins.

That's not to say we encourage naming functions after reserved words.  I
doubt anybody would call that "good style".  But if there's no technical
reason to stop it, why do so?

--Brent Dax <brent@brentdax.com>
Perl and Parrot hacker
 
"Yeah, and my underwear is flame-retardant--that doesn't mean I'm gonna
set myself on fire to prove it."


Thread Previous


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