Re: Checking for nil return

2020-12-31 Thread Darren Duncan
On 2020-12-29 6:26 a.m., Ruud H.G. van Tol wrote: Basically, never mix error-state and return-value. Rather use a different channel/dimension for each. Such a separation can't be absolute though. One needs to be able to user-define routines that implement additional generic Failure related

Re: Checking for nil return

2020-12-31 Thread yary
Moving the "can't catch Nil return, why is Nil also a failure?" question to a Raku issue, https://github.com/Raku/doc/issues/3760 This got me going through Raku source code to see where Nil gets passed through; this looks promising. rakudo/src/vm/moar/spesh-plugins.nqp line 308

Re: Checking for nil return

2020-12-30 Thread yary
This commit shows where Nil expanded from being "Absence of a value" to, alternatively, "a benign failure". Unfortunately I haven't found discussion on "benign failure" – semantics, use case, prior art, example, that sort of thing – and the commit doesn't elaborate.

Re: Checking for nil return

2020-12-29 Thread Ruud H.G. van Tol
Basically, never mix error-state and return-value. Rather use a different channel/dimension for each. And any value itself can have special state too, like "absence" and (via its type) "has-default". On that docs-page, my stomach protested against the Nil/default pairing. Now I need to

Re: Checking for nil return

2020-12-28 Thread Brad Gilbert
The closest to null is actually an undefined type object On Mon, Dec 28, 2020, 3:36 PM yary wrote: > Been thinking about this, and checked out the Rakudo repository to peek > into the source. > > Allowing Failure as a return always makes sense to me– every block needs > to be capable of passing

Re: Checking for nil return

2020-12-28 Thread yary
Been thinking about this, and checked out the Rakudo repository to peek into the source. Allowing Failure as a return always makes sense to me– every block needs to be capable of passing along a failure, that's how the language is designed. On the other hand, Nil is not a Failure. Conceptually

Re: Checking for nil return

2020-12-20 Thread Brad Gilbert
Nil is always a valid return value regardless of any check. This is because it is the base of all failures. On Sat, Dec 19, 2020, 8:17 PM yary wrote: > Is this a known issue, or my misunderstanding? > > > subset non-Nil where * !=== Nil; > (non-Nil) > > sub out-check($out) returns non-Nil {

Re: Checking for nil return

2020-12-20 Thread yary
After writing that email, I remembered a bit of logic from a class long ago, that any assertion made on the empty set is true. Since Nil is a representation of no results, it would make sense to have assertions about it return true. I think this example shows an optimization to skip return type

Re: Checking for nil return

2020-12-20 Thread Joseph Brenner
yary wrote: > Is this a known issue, or my misunderstanding? > >> subset non-Nil where * !=== Nil; > (non-Nil) >> sub out-check($out) returns non-Nil { return $out } > >> out-check(44) > 44 >> out-check(Nil) > Nil > > ^ Huh, I expected an exception on "out-check(Nil)" saying the return value >