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

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

Thread Previous | Thread Next
From:
Stan
Date:
September 8, 2003 02:15
Subject:
Re: [perl #23754] Possible bug?; keywords for sub idenifier?
Message ID:
00a301c37592$e325b4c0$75e85540@hmr2
Thanks for clearing that up. It just seemed really odd when I first took
notice of that, giving my background in many over langs like C/C++, Java,
Cobol, PL/SQL, etc. I find it a pretty nifty feature actually :)

----- Original Message ----- 
From: "Brent Dax (via RT)" <perlbug-followup@perl.org>
To: <sr@blz.hmrprint.com>
Sent: Sunday, September 07, 2003 15:24 PM
Subject: RE: [perl #23754] Possible bug?; keywords for sub idenifier?


> 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 | 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