Skip to content

Unable to overload voodoo/magic by continuation types #235

Open
@shayanhabibi

Description

@shayanhabibi
import cps
type
  C = ref object of Continuation
  O = ref object of C
  P = ref object of C

proc sayYourName(c: C): string {.cpsVoodoo.} = return "I am C"
proc sayYourName(c: O): string {.cpsVoodoo.} = return "I am O"
proc sayYourName(c: P): string {.cpsVoodoo.} = return "I am P"

Either as magic or voodoo this considers them all to be redefinitions. If I change parameter field names this still occurs.

Even if the objects ref different continuations I hit the same wall

type
  C = ref object of Continuation
  Z = ref object of Continuation
proc sayYourName(c: C): string {.cpsVoodoo.} = return "I am C"
proc sayYourName(c: Z): string {.cpsVoodoo.} = return "I am Z"

Changing parameter names does not help, leorize has offered knowledge into the origin of the matter.

WORK AROUND:
His suggestion was to split the calls into separate modules. Doing so I was able to overload the calls and successfully make dynamic dispatch calls with continuations

See https://github.com/shayanhabibi/cpslearning/blob/main/dynamicdispatch/main.nim

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions