Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial incompatibility with Sort::Key #413

Open
lokapal opened this issue Sep 15, 2017 · 3 comments
Open

Partial incompatibility with Sort::Key #413

lokapal opened this issue Sep 15, 2017 · 3 comments

Comments

@lokapal
Copy link

lokapal commented Sep 15, 2017

Hello!

Your B::C is very good (and important!) Perl subsystem but unfortunately I cannot use it for really important project. This code:

`#!/usr/bin/perl

use strict;
use Sort::Key::Maker BED_keysort => qw(integer integer);

my @unsorted;
for (my $i=0;$i<10;$i++) { $unsorted[$i] {beg} = $i;
                                          $unsorted[$i] {center} = 20-$i;   }
print "Unsorted:\nBeg:\t";   for (my $i=0;$i<10;$i++) { print "$unsorted[$i]{beg} "; }.
print "\n";
print "Center:\t";for (my $i=0;$i<10;$i++) { print "$unsorted[$i]{center} "; }.
print "\n";

BED_keysort_inplace { $_->{center}, $_->{beg} } @unsorted;

print "Sorted\nBeg:\t";   for (my $i=0;$i<10;$i++) { print "$unsorted[$i]{beg} "; }.
print "\n";
print "Center:\t";for (my $i=0;$i<10;$i++) { print "$unsorted[$i]{center} "; }.
print "\n";`

Is running Ok in pure Perl, compiles by perlcc without any problems, but if I try to run it the answer is:
Undefined subroutine &main::BED_keysort_inplace called at test.pl line 15.
Perl:
This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-linux-gnu-thread-multi (with 44 registered patches, see perl -V for more detail)
OS: Ubuntu 14.04.5 LTS

The problem obviously is in the string
BED_keysort_inplace { $->{center}, $->{beg} } @unsorted;

_inplace are dynamically created functions made by main sorting module Sort::Key

@rurban
Copy link
Owner

rurban commented Sep 15, 2017

With typical errors like this you need to give the compiler the hint not to drop this package. Use the perlcc -uSort::Key flag if this is the package of the generated sub.

@lokapal
Copy link
Author

lokapal commented Sep 15, 2017

forward$ perlcc -uSort::Key::Maker -uSort::Key --staticxs test.pl forward$ ./test Unsorted: Beg: 0 1 2 3 4 5 6 7 8 9 Center: 20 19 18 17 16 15 14 13 12 11 Undefined subroutine &main::BED_keysort_inplace called at test.pl line 15.
What can I do more?

@rurban
Copy link
Owner

rurban commented Sep 22, 2017

Ok, I've looked at it, and it seems to be very tricky.
BED_keysort_inplace is basically created by the importer to

sub BED_keysort_inplace (&@) {
    my $keygen = shift;
    @_ or die "too few keys";
    my $ptypes = Sort::Key::Types::combine_types(@_);
    my $sub = Sort::Key::Types::combine_sub($keygen, undef, @_);
    return Sort::Key::_multikeysorter_inplace($ptypes, $sub, undef);
}

but even with that it does not work. Need to figure out what the importer does.

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

No branches or pull requests

2 participants