develooper Front page | perl.perl5.changes | Postings from May 2020

[Perl/perl5] 7aca95: Add dualvar-creating newSVivpv and newSVivpvn

From:
Paul Evans
Date:
May 26, 2020 20:41
Subject:
[Perl/perl5] 7aca95: Add dualvar-creating newSVivpv and newSVivpvn
Message ID:
Perl/perl5/push/refs/heads/leonerd/newSVivpv/5fff32-f90760@github.com
  Branch: refs/heads/leonerd/newSVivpv
  Home:   https://github.com/Perl/perl5
  Commit: 7aca95638d573246006aeee59061b6dfc17754f7
      https://github.com/Perl/perl5/commit/7aca95638d573246006aeee59061b6dfc17754f7
  Author: Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
  Date:   2020-05-26 (Tue, 26 May 2020)

  Changed paths:
    M MANIFEST
    M embed.fnc
    M embed.h
    M ext/XS-APItest/APItest.pm
    M ext/XS-APItest/APItest.xs
    A ext/XS-APItest/t/newSVivpv.t
    M proto.h
    M sv.c

  Log Message:
  -----------
  Add dualvar-creating newSVivpv and newSVivpvn

These two new functions create IV-and-PV dualvars, in similar style to
the other newSV*() family.

They are most convenient for wrapping error values from external
libraries, to create dual number/string values in a similar style to
core's $! wrapping of errno.

For example:

    int err = uv_...();
    if(err != 0) return newSVivpv(err, uv_strerr(err));

This makes the usual style of error-type dualvar that can both be tested
for numerical equality and additionally used as a string to yield its
human-readable error message

    croak "Unable to complete: $err" unless $err == UV::UV_EAGAIN;


  Commit: f90760bb52ee995d856d400091cc14933ecb26fc
      https://github.com/Perl/perl5/commit/f90760bb52ee995d856d400091cc14933ecb26fc
  Author: Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
  Date:   2020-05-26 (Tue, 26 May 2020)

  Changed paths:
    M handy.h

  Log Message:
  -----------
  Also add a newSVivpvs() macro to handy.h


Compare: https://github.com/Perl/perl5/compare/5fff328743f8...f90760bb52ee



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