Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

RE: History of 'our'

by reptile (Monk)
on Jul 22, 2000 at 22:51 UTC ( #23916=note: print w/replies, xml ) Need Help??

in reply to History of 'our'

'our' has been reserved in versions earlier than 5.6.0. Saying it's deprecated is likely just bad wording. In 5.6.0, the 'our' keyword is synonymous with 'use vars' to declare package globals. This is AFAIK (one of the 5.005* perldelta pages, i believe, mentions that 'our' has been reserved).

local $_ = "0A72656B636148206C72655020726568746F6E41207473754A"; while(s/..$//) { print chr(hex($&)) }

Replies are listed 'Best First'.
RE: RE: History of 'our'
by merlyn (Sage) on Jul 23, 2000 at 08:03 UTC
    In 5.6.0, the 'our' keyword is synonymous with 'use vars' to declare package globals.
    Uh, no. Not quite. It's use vars but with lexical scoping, so if it's inside a block, it loses effect after the block.

    -- Randal L. Schwartz, Perl hacker

RE: RE: History of 'our'
by japhy (Canon) on Jul 23, 2000 at 07:07 UTC
    No, saying "use of reserved word XXX is deprecated" is a very proper message; you're using a bareword, and Perl is letting you know you shouldn't, since it's reserved for a future use. Perl didn't say "use of XXX is deprecated."


      Okay, I consider myself a fairly advanced Perl programmer (after over a dozen years of it), but I find that distinction pretty danged subtle. I'd say the message "use of reserved word XXX is deprecated" is very poorly worded. It very much sounds like "use of XXX is deprecated, and, by the way, it is a reserved word".

      The existence of perldiag.pod helps relieve this problem (it says "Future versions of perl may use it as a keyword..." for this message).

      But it is still terrible because the meaning of "reserved word" in C (the only other place I've heard that term) is "a word reserved for use by the language", that is "if", "else", "goto", etc. So a "reserved word" in C is the same as a "keyword" in Perl.

      It is strange that Perl, a language that takes much from C, to use C's phrase for "keyword" as Perl's phrase for "not yet a keyword".

      In fact, I just did some checking of my facts, and I found the use of the term "reserved word" for what Perl calls "keyword" in several places other than C. In fact, Perl uses the term "reserved word" to include current keywords (see perldata.pod) so to say "'our' is a reserved word" doesn't even tell you that "our" isn't currently a keyword.

      A much better error message would be "The bareword XXX may become a Perl keyword, please quote it". *sigh*, now I have a moral obligation to submit a patch. :)

      OK. </rant>

        This is what perldiag has to say:
        Unquoted string "%s" may clash with future reserved word
        (W) You used a bareword that might someday be claimed as a reserved word. It's best to put such a word in quotes, or capitalize it somehow, or insert an underbar into it. You might also declare it as a subroutine.
        Use of reserved word "%s" is deprecated
        (D) The indicated bareword is a reserved word. Future versions of perl may use it as a keyword, so you're better off either explicitly quoting the word in a manner appropriate for its context of use, or using a different name altogether. The warning can be suppressed for subroutine names by either adding a & prefix, or using a package qualifier, e.g. &our(), or Foo::our().
        I sense a distinction between 'keyword' and 'reserved word'. All keywords are reserved words, but not all reserved words are keywords (yet).

        I personally never found this confusing, but if you feel morally opposed to it, send a patch on over to P5P. :)

        after over a dozen years of it

        Perl 1 was introduced in Dec of 87, so has only been been around a little over a dozen years. You mean you have been around since pre Perl 1? Since you are bragging on how long you have been doing Perl, I assume you have some cool Perl of yours to look at somewhere. I would be interested in seeing some high caliber Perl done by a veteran of over 12 years of doing Perl.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://23916]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2018-03-18 14:34 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (230 votes). Check out past polls.