given this test
proc test() =
var a: string
echo a == nil
a = ""
echo a == nil
var b: seq[int]
echo b == nil
b = @[]
echo b == nil
test()
Nim 0.18.0 produces:
false
true
false
After commit correct comparisons for nil strings/seqs it produces:
true
true
true
Is this really what you mean by correct comparisons for nil strings/seqs?
(issue #8136 is related to this)
I think now nil seq/string is the same thing as empty seq/string and #8136 needs to be fixed accordingly with that change
in the changelog we have this:
nil for strings/seqs is finally gone. Instead the default value for"" / @[].I don't understand how this could imply that both "" == nil and @[] == nil are now true, while isNil("") and isNil(@[]) remain false as before.
I've said it before. New strings/seqs are coming and nil and isNil will fail to compile. No confusion will be possible.
Excellent! Good luck with this abitious endeavor!
can this be closed then?
Not as long as isNil(str) compiles.
This will break my book :(
This example at least: https://github.com/nim-lang/Nim/blob/devel/tests/niminaction/Chapter2/resultaccept.nim
@dom96 I am sorry for you. But it will be for the greater good. And I think your example will still be understandable and valuable even if nil won't exist anymore in the language.
can this be closed then?
Not as long as
isNil(str)compiles.
isNil(str) doesn't compile anymore. This can be closed.
Most helpful comment
@dom96 I am sorry for you. But it will be for the greater good. And I think your example will still be understandable and valuable even if nil won't exist anymore in the language.