difference between None, Nothing and nothing

1,806 views
Skip to first unread message

Michele Zaffalon

unread,
May 5, 2014, 1:55:56 AM5/5/14
to julia...@googlegroups.com
I could not see anything in the docs and I could only understand the "nothing" keyword:

julia> function f()
       return
       end
f (generic function with 1 method)

julia> f()==nothing
true

julia> nothing==Nothing
false

julia> nothing==None
false

julia> Nothing==None
false

julia> Nothing==Nothing
true

What is the meaning of Nothing and None?

Thank you,
michele

Jameson Nash

unread,
May 5, 2014, 2:11:48 AM5/5/14
to julia...@googlegroups.com
Nothing is the type of nothing. An empty return statement implicitly
returns nothing.

julia> isa(nothing, Nothing)
true

julia> nothing === Nothing()
true

None is the type union representing the absence of Any type. You
cannot have an instance of type None.

julia> Nothing <: None
false

julia> None <: Nothing
true

julia> Nothing <: Any
true

julia> Any <: Nothing
false

Michele Zaffalon

unread,
May 5, 2014, 2:29:34 AM5/5/14
to julia...@googlegroups.com
Now it is clear, thank you.
Wouldn't it make sense to add it to the docs?

Jameson Nash

unread,
May 5, 2014, 2:33:08 AM5/5/14
to julia...@googlegroups.com
Yes. Can you suggest a good place for it or submit a pull request (you
can edit the manual directly in a browser to create a pull request
https://github.com/JuliaLang/julia/tree/master/doc/manual)?

On Mon, May 5, 2014 at 2:29 AM, Michele Zaffalon

Ivar Nesje

unread,
May 5, 2014, 2:52:25 AM5/5/14
to julia...@googlegroups.com

Michele Zaffalon

unread,
May 5, 2014, 3:42:54 AM5/5/14
to julia...@googlegroups.com
Ah, I could not find it. Searching the docs for "none nothing" "none || nothing" "none or nothing" does not seem to find it. Only null returns the FAQ but null is not a julia keyword, so it is less likely to be searched than none.

Ivar Nesje

unread,
May 5, 2014, 3:57:47 AM5/5/14
to julia...@googlegroups.com
I get FAQ as the 3. and 6. result on release-0.2 and latest documentation when i search for "nothing".

Michele Zaffalon

unread,
May 5, 2014, 4:10:21 AM5/5/14
to julia...@googlegroups.com
I don't, please see attachment. And there is nothing (ah!) relevant in the list.
search.png

Ivar Nesje

unread,
May 5, 2014, 4:39:24 AM5/5/14
to julia...@googlegroups.com
The last (partially visible) search result says Frequently Asked Questions (commonly abbreviated FAQ). I count 5 results above it, thus it must be the 6th result.

The search should probably index the FAQ entries individually, but it is still fairly simple to find.

Michele Zaffalon

unread,
May 5, 2014, 5:20:00 AM5/5/14
to julia...@googlegroups.com
6th entry refers to the top of the FAQ. But you are right, if I click the link and scroll down, nothing is highlighted. On the other hand, searching for nothingness points me to the exact place.

Ivar Nesje

unread,
May 5, 2014, 5:57:07 AM5/5/14
to julia...@googlegroups.com
Our search functionality (as provided by readthedocs) does not seem to scroll the result page for any query. ctrl-f / cmd-f is usually the best way to find something when the search engine landed you on the correct page.

Ivar
Reply all
Reply to author
Forward
0 new messages