he scalar is having its reference count dropped twice -- once when you leave the XS function, and once when @_ is cleaned up after that function returns.
Thankyou. That was the bit I was not getting.
The reason for wanting to handle the case of readonly inputs is that I cannot guarentee that the caller (should this ever get into the wild), won't pass a constant that becomes the first parameter.
The reason for wanting to return the argument is the same reason that I can do
print $scalar1 .= $scalar2;
I hate modules that force me to do
my $arg = 1; someMutator( $arg ); print $arg;
Instead of
print someMutator( 1 );
Try using Tk if its methods did not return the object:
my $widget = Tk::SomeWidget->new( ... ); $widget->Add( ... ); $widget->pack( ... );
Instead of
my $widget = Tk::SomeWidget->new( ... )->Add( ... )->pack( ... );
So, now I understand why the increment is necessary, can you clarify what is wrong (technically rather than preference), with doing an increment to counter one of the decrements?
In reply to Re^2: XS/Inline::C concat *any* two SVs.
by BrowserUk
in thread XS/Inline::C concat *any* two SVs.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |