Skip to content

warn or fail on stringify/numify of a type object? #17

pmichaud opened this Issue Jul 7, 2012 · 3 comments

3 participants

Perl 6 member
pmichaud commented Jul 7, 2012

Does numifying or stringifying a type object
produce an immediate 'warn' or a Failure? What's the
expected result from:

my $x;
my $y = +$x;
say 'alive';
say $y;

Is the warning generated at the point of assignment to $y
or at the point where $y is used?


s1n commented Jul 9, 2012
Perl 6 member
@TimToady TimToady added a commit that closed this issue Jul 28, 2012
@TimToady TimToady resumable failures for coercions
fixes #17
@TimToady TimToady closed this in 5dfd996 Jul 28, 2012
Perl 6 member

These marginal conversions should fail() with a resumable warning for the exception, and the warning should support a .resume_value that can return the best guess at what was intended, 0 for +"foo", and 42 for +"42junk". (The default in the absence of a .resume_value is the null string.)

By using fail() we allow 'use fatal' to trap them immediately, and we allow parallel algorithms to check for definedness of individual results without having to install a special warning handler. The //die idiom will tend toward a fatal interpretation, while sinking such a half-defined value will warn but survive. The payload of the failure can be hand-checked for a .resume_value if desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.