in reply to Re: Creating wrapper over a wrapper
in thread Creating wrapper over a wrapper

use ABC ();
This also doesn't work. I still get errors.
Too many arguments for ABC::new_time_var at /u/agarwsun/projects/packages/datelib/lib/perl5/5.8.6/i86pc-solaris/ABC.pm line 71, near "@_)"

Not enough arguments for ABC::dl_ascii_to_time at /u/agarwsun/projects/packages/datelib/lib/perl5/5.8.6/i86pc-solaris/Deshaw/ABC.pm line 81, near "@_)"

Not enough arguments for ABC::dl_compare at /u/agarwsun/projects/packages/datelib/lib/perl5/5.8.6/i86pc-solaris/Deshaw/ABC.pm line 91, near "@_)"

The actual signatures of these subroutines are:
<new_time_var>() <dl_ascii_to_date>(<string>) <dl_ascii_to_time>(<string>, <dtp>)

Replies are listed 'Best First'.
Re^3: Creating wrapper over a wrapper
by almut (Canon) on May 06, 2010 at 07:27 UTC

    Well, if the ABC::new_time_var function is declared with a prototype of (), meaning no arguments, you cannot call it with arguments in your wrapper, like ABC::new_time_var(@_).  Similarly for the other two functions.

    See also other threads on using prototypes here, to better understand how prototypes work in Perl (hint: they don't act like in C).

      But how come then passing @_regardless the number of arguments function expects, works fine in case we write a wrapper over a pure perl module?

        This has nothing to do with with XS or not.  It's solely a matter of whether there's a prototype declared for the function.  The exact same problem exists for pure-Perl modules:

        #!/usr/bin/perl package ABC; sub new_time_var () { # ^^prototype print "ABC::new_time_var() called.\n"; } package PQR; sub new_time_var { ABC::new_time_var(); # prototype-compatible call --> works ABC::new_time_var(@_); # incompatible --> "Too many arguments for + ABC::new_time_var ..." } new_time_var();
        Please express your question in code.

        Maybe you want to read perlsub again (esp section on prototypes)?

        $ perl -le" sub mysplice (\@$$@){ warn@_} sub QQQ(\@$$@) { goto &mysp +lice } QQQ @a, 1,1" ARRAY(0x97a064)11 at -e line 1.