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

Rakudo should return Nil, not Failure, when an optionally called method wasn't called because it didn't exist in Rakudo #1496

Closed
p6rt opened this issue Feb 13, 2010 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Feb 13, 2010

Migrated from rt.perl.org#72790 (status was 'resolved')

Searchable as RT72790$

@p6rt
Copy link
Author

p6rt commented Feb 13, 2010

From @masak

<TimToady> rakudo​: my $result = 0xdeadbeef.?deadbeef; say $result
<p6eval> rakudo 1d4928​: OUTPUT«Undefined value returned by invocation
of undefined method␤␤»
<TimToady> another case where rakudo returns a Failure that should
probably just return Nil
<jnthn> TimToady​: Really?
<TimToady> I told it the call was optional
<jnthn> Hmm...true.
<masak> rakudo​: my $a; say ($a.?foo).WHAT
<p6eval> rakudo 1d4928​: OUTPUT«Failure()␤»
* masak submits rakudobug
<jnthn> The failure is easy to distinguish though. If I expected no
results, it's harder to distinguish that from "nothing was called".
<jnthn> That is, a method that just did return; would return Nil too, no?
<TimToady> sure, though we could distinguish those in slice context, presumably
<jnthn> Or if you were interesteed in the failure I guess use . and a try/CATCH
<jnthn> Since presumably you want to do something on the failure anyway.
<TimToady> I prefer exceptions to be reserved for unexpected things
<jnthn> Yeah, good point.
<TimToady> use of Failure as a normal return value is a design smell
<jnthn> OK, we'll Nil it. :-)
<jnthn> .oO( TimToady 1 - Nil jnthn )
<TimToady> basically, .* and by extension .? should return something
sliceable to get the number of successful returns as subparcels
<jnthn> Parcel of Parcels?
<TimToady> presumably
<jnthn> wfm
<masak> oh, that's an even better explanation.
<masak> it should be Nil because it's an empty list.
<masak> parallel to quantifier ? returning an empty list upon no match.
<TimToady> Parcel(Nil) is a real returned Nil, whille Nil is no parcels
<TimToady> masak​: nodnod

@p6rt
Copy link
Author

p6rt commented Feb 27, 2010

From @jnthn

<TimToady> another case where rakudo returns a Failure that should
probably just return Nil
<jnthn> TimToady​: Really?
<TimToady> I told it the call was optional
<jnthn> Hmm...true.
<masak> rakudo​: my $a; say ($a.?foo).WHAT
<p6eval> rakudo 1d4928​: OUTPUT«Failure()␤»

It now returns Nil. Tests needed.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Feb 27, 2010

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Feb 28, 2010

From @moritz

Tested in S12-methods/calling_sets.t.

@p6rt
Copy link
Author

p6rt commented Feb 28, 2010

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Feb 28, 2010
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant