Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Recently in the pub I was talking about forward compatibility between perl5 and perl6 with Nicholas Clark, the current perl 5.8 pumpking. We have been promised that perl6 will also run older perl5 programs, despite quite a lot of incompatible feature changes between the two versions of the language. So how will perl6 be able to tell whether code is written in perl5 or perl6? Or whether it's buggy perl5, correct perl5, buggy perl6, or correct perl6? Heuristics can only get you part of the way, so some kind of explicit marker which definitively says "this is perl5" would be a Good Thing. And it would also be a Good Thing if that mechanism could be used right now in perl5 programs, so that we can start our migration to perl6 by at least ensuring that existing code is forward-compatible.

So I took this to the perl6-language list, suggesting a perl5 pragma "use perl5;" which would be that marker for the perl6 interpreter, but in perl5 would be a null pragma.

However, it turns out that there is already such a mechanism. perl6 will not use the "package" keyword, and will take its presence to mean "this is perl5 code". So existing modules should work already.

But what about scripts and programs? They don't generally say "package" anywhere. But, if you don't specify a package, that just means use the default package, which is called "main". The solution therefore is to insert, at the top of all your scripts and programs, this line:

package main;

Go and do it today. Tell your friends. Get yourself ready for the shiny new perl6 world.


In reply to Ensuring forward compatibility by DrHyde

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-19 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found