Hi
I stumbled across of this error:
visualisation\messages.nim(28, 11) template/generic instantiation from here
lib\system.nim(347, 10) template/generic instantiation from here
lib\system.nim(2305, 3) Error: parallel 'fields' iterator does not work for 'case' objects
line 28: if mc != nil:
type MessageTypes* = enum msgHit, msgMiss
type Message* = object
case messageType*: MessageTypes
of msgHit:
target: string
hp: int
of msgMiss:
discard
type MessageClient* = seq[Message]
proc addMessage*(mc: var MessageClient, m: Message) =
if mc != nil: # line 28
discard
What am I doing wrong?
Nim Compiler Version 0.16.0 (2017-01-08) [Windows: i386]
Copyright (c) 2006-2017 by Andreas Rumpf
git hash: b040f74356748653dab491e0c2796549c1db4ac3
active boot switches: -d:release
Compiled with:
nim c --parallelBuild:1 src\main.nim
Thank you.
I feel I still cannot wrap around pointer and value types in Nim. I thought that since I am comparing seq[T] and not elements T it is sufficient to compare just address. And since seq is kept on heap I expected mc just to be pointer (or reference). Since I do not want to compare sequences or elements but just check if it was constructed at all, I do not need ==. Is just
if cast[pointer]mc != nil: ...
acceptable solution? What is better? How should it look like? Well... I expected something like that should be somewhere so I was searching for this and could not found. I put "nil" word in search box and none of results matched.
Similar situation, I could swear I have seen line end constant (like EOL="nr" for instance) and could not find any more.
Well I thought somewhere it is defined for me, something like
when windows:
const endl = r"\r\n"
when linux:
const endl = r"\n"
...