develooper Front page | perl.perl5.porters | Postings from August 2017

Re: Shouldn't we be fixing our function interfaces to removeinappropriate I32 U32?

Thread Previous
From:
Zefram
Date:
August 10, 2017 23:19
Subject:
Re: Shouldn't we be fixing our function interfaces to removeinappropriate I32 U32?
Message ID:
20170810231858.GR9383@fysh.org
Karl Williamson wrote:
>I'm unsure of the implications for modules that can work on earlier perls.

The implication is that the module may need to define a typedef for
that part of the API, in a Perl-version-dependent manner.  For example,
some of my modules have

    #if PERL_VERSION_GE(5,19,4)
    typedef SSize_t array_ix_t;
    #else /* <5.19.4 */
    typedef I32 array_ix_t;
    #endif /* <5.19.4 */

Whether this is required depends on the details of the module's code.
Not every use of API functions involving the changed type requires the
module to be this aware.  With array indexing, a simple "av_fetch(av, 0,
0)" (with a fixed small index) doesn't require it, but iterating over
a variable-length array requires it, because the module must declare
variables in which to store the top index and the iteration index.

In practice, a lot of preexisting modules probably don't get this kind
of update.  The module will generally still compile, probably without
even a warning, and will still work fine as long as the values seen stay
within the limits of the old type.  They'll go spectacularly wrong if
they actually encounter an object bigger than the old type can represent.

-zefram

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About