Skip to content
This repository has been archived by the owner on Jan 23, 2022. It is now read-only.

use PDL::Lite; only loads functions for first package it is called in #11

Closed
shawnlaffan opened this issue Aug 31, 2015 · 1 comment
Closed

Comments

@shawnlaffan
Copy link

[ Reposted from PDLPorters/pdl#146 - will look into a PR if I get a chance ]

Using PDL::Lite in more than one package only imports pdl and the other standard functions in the first package it is called from.

Code to reproduce is below.

The code works if use PDL::Lite is replaced with with use PDL or use PDL::LiteF, or if pdl() is set using a glob.

If a use PDL::Lite is put before the first package declaration then neither sub call works.

Tested on StrawberryPerl 5.20, pdl 2.012 and pdl 2.013.

Regards,
Shawn.

package mk1 {
    use PDL::Lite;

    sub x {
        return pdl (1..10);
    }
}

package mk2 {
    use PDL::Lite;
    #*pdl = \&PDL::Core::pdl;  #  uncomment and the code works
    sub x {
        return pdl (11..20);
    }
}

print mk1::x, "\n";  #  [1 2 3 4 5 6 7 8 9 10]
print mk2::x, "\n";  #  Undefined subroutine &mk2::pdl called at xx.t line 21.
shawnlaffan added a commit to shawnlaffan/pdla-core that referenced this issue Sep 20, 2015
Otherwise only the first caller would have these functions loaded, and it would thus not match the documentation.

This issue has been around for a long time, as it pre-dates the addition of the package statement in 87487f0 .

Also update the documentation to be clear about which methods are exported, and encourage the method calling syntax regardless.

An alternative is to export nothing and document the method syntax as the only approach, but that would lead to CPAN breakage for those that rely on pdl() etc being exported (albeit such packages will not work if they are loaded second anyway).

Updates issue PDLPorters#11
shawnlaffan added a commit to shawnlaffan/pdla-core that referenced this issue Sep 20, 2015
shawnlaffan added a commit to shawnlaffan/pdla-core that referenced this issue Sep 20, 2015
shawnlaffan added a commit to shawnlaffan/pdla-core that referenced this issue Sep 20, 2015
shawnlaffan added a commit to shawnlaffan/pdla-core that referenced this issue Sep 20, 2015
shawnlaffan added a commit to shawnlaffan/pdla-core that referenced this issue Sep 20, 2015
shawnlaffan added a commit to shawnlaffan/pdla-core that referenced this issue Sep 20, 2015
shawnlaffan added a commit to shawnlaffan/pdla-core that referenced this issue Sep 20, 2015
shawnlaffan added a commit to shawnlaffan/pdla-core that referenced this issue Sep 20, 2015
@shawnlaffan
Copy link
Author

Closing as superseded (see #12 )

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant