in reply to Procedural and object oriented interface in Perl/XS

Perl doesn't make any distinction between a function call and a method call (except that which function to call is resolved at run-time). $x->foo($y,$z) just calls foo($x,$y,$z),and Class->foo($y,$z) just calls foo('Class',$y,$z).

So if you want your function (be it perl or XS code) to tell the difference, you need to make the function be called in a slightly different way to make a distinction

Dave.

  • Comment on Re: Procedural and object oriented interface in Perl/XS

Replies are listed 'Best First'.
Re^2: Procedural and object oriented interface in Perl/XS
by stewa02 (Novice) on Oct 23, 2014 at 13:14 UTC

    Well the difference is: the method call gives the instance of the object as the only argument, the function call a number (For cos: $instance->cos; or MyModule::Math::cos(42);) and thats what I try to do with sv_isobject(). But this dows not work and I don't see my error.

      But this dows not work
      Can you be much more specific please. In which way does it not work? Under what circumstances does it not work? Have you single-stepped that XS function under a debuggger? At what point does the behaviour deviate from what you expect? Etc.

      Dave.