## INVALID
type
Something = object
act* : proc()
name*: string
var something = Something(.act : someaction)
proc someaction*()=
something.name = "boo"
## VALID
type
Something = object
act* : proc()
name*: string
var something = Something()
something.act = someaction
proc someaction*()=
something.name = "boo"
## VALID
type
Something = object
act* : proc()
name*: string
var something = Something()
something.act = someaction
proc someaction*()=
# some code without something
discard
Why the first example is invalid ? The error gives me undeclared identifier but I don't understand what it means since I see the identifier.
You can forward declare procs to reference them before they are defined.
type
Something = object
act*: proc()
name*: string
proc someaction*()
var something = Something(act: someaction)
proc someaction*() =
something.name = "boo"
Sorry, but your second example is no more valid than the first one.
In both cases, as @Hlaaftana said, you need to declare the proc before referencing it.