Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dualvar-creating newSVpviv and friends #17811

Closed
wants to merge 1 commit into from
Closed

Conversation

leonerd
Copy link
Contributor

@leonerd leonerd commented May 28, 2020

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;

(this PR is a continuation of #17807 which I shall now close)

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;
@toddr
Copy link
Member

toddr commented Jul 30, 2020

@leonerd per the mailing list, does this change need more work or are we discarding it?

@jkeenan
Copy link
Contributor

jkeenan commented Jan 26, 2021

@leonerd per the mailing list, does this change need more work or are we discarding it?

@leonerd, is this p.r. something you expect to be able to get back to in the near future?

If not, I'd recommend closing it and coming back to the matter later.

Thank you very much.
Jim Keenan

{
SV *sv = newSViv(i);
if(!sv) return newSViv(i);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code above doesn't make sense.

@leonerd leonerd closed this May 8, 2021
@leonerd leonerd deleted the leonerd/newSVpviv branch May 8, 2021 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants