Coder Social home page Coder Social logo

chocolateboy / autobox Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 8.0 558 KB

Call methods on native types

Home Page: https://metacpan.org/release/autobox

License: Artistic License 2.0

Perl 82.24% XS 13.55% C 4.21%
extension-methods lexical autobox autoboxing pragma perl-pragma perl-module xs scope scoped

autobox's People

Contributors

chocolateboy avatar chorny avatar djerius avatar dsteinbrunner avatar edwardbetts avatar eserte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

autobox's Issues

version.pm must be used to support version tuples on perl 5.8

version.pm is not used for core version comparisons until 5.10 or if it's loaded. So to support 5.8, version tuples should be declared like (on a single line):

use version 0.77; our $VERSION = version->declare('v3.0.0');

and version should be added to your module's runtime dependencies. See http://blogs.perl.org/users/grinnz/2018/04/a-guide-to-versions-in-perl.html under Declaring Versions, and https://metacpan.org/pod/version#How-to-declare()-a-dotted-decimal-version.

Build fails with Perl 5.25

Accordng to perl5220delta, one needs to use macros to access the sibling informations

cc -c  -I.  -O2 -pipe  -fstack-protector -fno-strict-aliasing -O3 -Wall    -DVERSION=\"2.83\"  -DXS_VERSION=\"2.83\" -DPIC -fPIC "-I/usr/local/lib/perl5/5.25/mach/CORE"   autobox.c
autobox.xs:31:43: error: no member named 'op_sibling' in 'struct op'
        UNOP *parent = (cUNOPo->op_first->op_sibling) ? cUNOPo : ((UNOP*)cUNOPo->op_first);
                        ~~~~~~~~~~~~~~~~  ^
autobox.xs:33:24: error: no member named 'op_sibling' in 'struct op'
        OP *o2 = prev->op_sibling;
                 ~~~~  ^
autobox.xs:36:31: error: no member named 'op_sibling' in 'struct op'
        for (cvop = o2; cvop->op_sibling; cvop = cvop->op_sibling);
                        ~~~~  ^
autobox.xs:36:56: error: no member named 'op_sibling' in 'struct op'
        for (cvop = o2; cvop->op_sibling; cvop = cvop->op_sibling);
                                                 ~~~~  ^

Fails tests without '.' in @INC

On 5.25.10 with -Ddefault_inc_excludes_dot

PERL_DL_NONLAZY=1 "/home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/bin/perl5.25.10" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
Can't locate autobox_scope_1.pm in @INC (you may need to install the autobox_scope_1 module) (@INC contains: ../lib /home/kent/.cpanm/work/1488218060.1141/autobox-2.84/blib/lib /home/kent/.cpanm/work/1488218060.1141/autobox-2.84/blib/arch /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/site_perl/5.25.10 /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.10-nossp-sdbm-nopmc-nodot/lib/5.25.10) at t/all.t line 667.
BEGIN failed--compilation aborted at t/all.t line 667.
# Looks like your test exited with 2 before it could output anything.
t/all.t ............. 
Dubious, test returned 2 (wstat 512, 0x200)

Documentation needs to be clearer about consumption

I was talking to somebody today on IRC, who was trying to use autobox and was being confused why none of the code in the synopsis as-is.

I think the synopsis and documentation needs to be more explict in that autobox.pm creates none of the methods, and autobox.pm is explicitly a toolkit for other autoboxing things to use, and that the synopsis is only an example of what could be done once all the relevant subs are installed in SCALAR::length() etc, and that unless somebody is explicitly authoring a autoboxing module, that they should probably be consuming an existing autoboxer, like autobox::Core or MooseX::Autobox

New versioning format breaks cpanm

We have this in the cpanfile for my project at work:

requires 'autobox', '>= 2.86';

Since 3.0.1 came out that's started to break:

Argument "^C\0^A" isn't numeric in numeric ge (>=) at ...

Pleeeeeease switch back to using numbers for versions, nothing else works reliably (yes, I'm going to report this as a bug against version.pm as well).

Does not work with Parallel::ForkManager on Windows

Windows 11 22H2, Strawberry Perl 5.32.1

Below is demo script. If you comment out that use autobox; line, it works great. But with use autobox; it termiates early silently.

use Parallel::ForkManager;

# comment out this line and it becomes good.
use autobox;

my $pm = Parallel::ForkManager->new(3);

$pm->run_on_finish(
    sub {
        my ( $pid, $exit_code, $ident, $exit_signal, $core_dump, $returned ) = @_;
        print "Child with ", $returned->{id}, " finished.\n";
    }
);

LOOP:
foreach my $id (0 .. 10) {
    my $pid = $pm->start and next LOOP;
    print "Starting with $id \n";
    my $return_data = {};
    $return_data->{id} = $id;
    $pm->finish( 0, $return_data );
}
$pm->wait_all_children;
print "is this gonna work???\n";

Could you make $el ~~ \@array work somehow?

In Perl 5.27.7 the right-hand side of the ~~ operator is supposed to be an object that has ~~ overloaded. So I thought that overloading ~~ on package ARRAY would let me create arrays' behaviour with ~~ as I wanted. But I found out that that does not do the trick (see my program here: https://gist.github.com/akarelas/feb1a870da15b1e729ebe718ede4d6ce )

I wonder if autobox could be modified to handle ~~ as well, or maybe there's a way to achieve what I want which I just don't know.

Spelling error

Hello,
a little Lintian report:

--- a/lib/autobox.pod
+++ b/lib/autobox.pod
@@ -540,7 +540,7 @@
 directly on native types produces the same results as calling them with autobox disabled
 e.g.:

-    42->isa('NUMBER') # "" (interpeted as "42"->isa("NUMBER"))
+    42->isa('NUMBER') # "" (interpreted as "42"->isa("NUMBER"))
     []->can('push')   # Error: Can't call method "can" on unblessed reference

 =head1 EXPORTS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.