Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Boolean ops on NA are broken #97

Open
johnmyleswhite opened this issue Jun 26, 2014 · 4 comments
Open

Boolean ops on NA are broken #97

johnmyleswhite opened this issue Jun 26, 2014 · 4 comments

Comments

@johnmyleswhite
Copy link
Member

julia> true || NA
true

julia> NA || true
ERROR: type: non-boolean (NAtype) used in boolean context
@simonster
Copy link
Member

I'm not sure we can fix this, nor am I sure there is a unique solution. && and || are not actually functions because they short-circuit, so we can't override them for NA. The short-circuiting behavior is also conceptually problematic: It's not clear what NA || error("hello world") is supposed to do.

@johnmyleswhite
Copy link
Member Author

God I hate that idiom. Will discuss with Jeff et al. later today.

@ivarne
Copy link

ivarne commented Oct 30, 2014

This is deliberate, as julia require all conditions for conditionals to be of type Bool. We could do an implicit convert(Bool, x) when the type doesn't match, but I think you'll have trouble convincing @StefanKarpinski and @JeffBezanson that it is a good idea.

Nothing prevents your from calling convert on NA manually though.

@johnmyleswhite
Copy link
Member Author

This won't matter any more once NA is replaced with Nullable{Bool}. No more three-valued logic.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants