Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Why not perl have raw/native type

by dave_the_m (Monsignor)
on Jan 09, 2020 at 07:56 UTC ( #11111227=note: print w/replies, xml ) Need Help??


in reply to Re^2: Why not perl have raw/native type
in thread Why not perl have raw/native type

How about:
# foo() is a sub from a 3rd party library you have no control over sub foo { my $r = \$_[0] } my native str $s = "..."; foo($s);

Dave.

Replies are listed 'Best First'.
Re^4: Why not perl have raw/native type
by LanX (Cardinal) on Jan 09, 2020 at 08:18 UTC
    Same xxx other colour:

    foo needs a function signature with the right type.

    And yes I know that subs can be redefined, but change of prototype is also emitting a warning.

    Really complicated are lvalue situations like aliasing!

    But hey, I never said it's easy... ;)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      You call a sub which is declared as accepting an integer arg - so perl pushes an int value dircectly onto the stack rather than the usual pointer to SV. But if someone in the meantime has redefined foo() to be a sub accepting a normal SV argument, then perl won't just do the wrong thing - it will likely crash with a SEGV, or even be a security hole, when it tries to interpret that integer value as the address of an SV.

      Dave.

        That's why I mentioned

        > > And yes I know that subs can be redefined, but change of prototype is also emitting a warning.

        Warnings to Fatals.

        > it will likely crash with a SEGV, or even be a security hole, when it tries to interpret that integer value as the address of an SV.

        I suppose using Inline::C or Inline::CPP is even worse, when it comes to such risks.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11111227]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2020-10-26 07:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (250 votes). Check out past polls.

    Notices?