Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^8: Howto "use" backward compability packages of new "feature"s

by LanX (Saint)
on Aug 25, 2010 at 09:38 UTC ( [id://857126]=note: print w/replies, xml ) Need Help??


in reply to Re^7: Howto "use" backward compability packages of new "feature"s
in thread Howto "use" backward compability packages of new "feature"s

and if you look further down pragmas are called "pseudo-modules".

I will open a ticket to add the "use stricter" example to the perldoc.

UPDATE:

pragmas are not even mentioned in require, it only talks about "library files" and do/eval file mechanisms.

Otherwise, require demands that a library file be included if it hasn't already been included. The file is included via the do-FILE mechanism, which is essentially just a variety of eval with the caveat that lexical variables in the invoking script will be invisible to the included code. Has semantics similar to the following subroutine: ...

Cheers Rolf

Replies are listed 'Best First'.
Re^9: Howto "use" backward compability packages of new "feature"s
by ikegami (Patriarch) on Aug 25, 2010 at 15:35 UTC

    You are saying there's some undocumented usage for pragmas. That's not true. use strict; matches the use Module; pattern, which is documented to be the same as BEGIN { require strict; strict->import(); }.

    Anyway, pragmas refers to modules that behave in a certain fashion. There's nothing special about them as far as Perl is concerned.

    pragmas are not even mentioned in require, it only talks about "library files"

    First you complain that "Modul"e is too specific, now you complained that the more generic term doesn't apply.

      pragmas are files???

      and if library files are the "more generic term", then my point should be clear!

      thank you! :)

      Cheers Rolf

        pragmas are files???

        Where were you planning on storing the code for stricter?

        then my point should be clear!

        I don't agree that

        use Module VERSION LIST use Module VERSION use Module LIST use Module use VERSION BEGIN { require Module; Module->import( LIST ); }
        is less clear than
        use LibraryFile VERSION LIST use LibraryFile VERSION use LibraryFile LIST use LibraryFile use VERSION BEGIN { require LibaryFile; Module->import( LIST ); }

        Especially since use doesn't take a file name.

Re^9: Howto "use" backward compability packages of new "feature"s
by JavaFan (Canon) on Aug 25, 2010 at 16:17 UTC
    pragmas are not even mentioned in require
    Note that pragmas don't exist on the language level. That is, Perl (the language) doesn't treat modules whose name is all lowercase different from modules who do not. "Pragmas" (or as some people call them "pragmata") are a loosly defined concept; typically as 'modules that influence the compilation process in some way'. But any module that exports prototyped subroutines influences compilation. And so do source filters. Many people consider "constant.pm" to be a pragma, but all it does is export subs with an empty prototype. But Fcntl and POSIX do so as well.

    Perhaps one could consider modules that set parts of @H and %H to be pragmas.

      they are called "compiler directives" in use which I think is quite OK.

      I just wanna know if I can "require+import" any pragma like I can do with "real" moduls.

      If yes I would like to consider to clarify this behavior in the documentation.

      Thats why I asked you to test if it works like this in your older perl installations.

      (something tells me that it wasn't always like it is now.)

      And if it can't be clearly documented because it's not a reliable feature only restricted to special pragmatas, I would like to know it.

      Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://857126]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-19 21:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found