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

[Perl/perl5] c9a797: Add dualvar-creating newSVpviv and friends

From:
Paul Evans
Date:
May 28, 2020 20:35
Subject:
[Perl/perl5] c9a797: Add dualvar-creating newSVpviv and friends
Message ID:
Perl/perl5/push/refs/heads/leonerd/newSVpviv/000000-c9a797@github.com
  Branch: refs/heads/leonerd/newSVpviv
  Home:   https://github.com/Perl/perl5
  Commit: c9a797974662f18ba2c6b3bd56069df5f3846c3d
      https://github.com/Perl/perl5/commit/c9a797974662f18ba2c6b3bd56069df5f3846c3d
  Author: Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
  Date:   2020-05-28 (Thu, 28 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/newSVpviv.t
    M handy.h
    M proto.h
    M sv.c

  Log Message:
  -----------
  Add dualvar-creating newSVpviv and friends

These two new functions and one macro create PV-and-IV 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 newSVpviv(uv_strerr(err), 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;



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