Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to overload voodoo/magic by continuation types #235

Open
shayanhabibi opened this issue Sep 14, 2021 · 3 comments · Fixed by #258
Open

Unable to overload voodoo/magic by continuation types #235

shayanhabibi opened this issue Sep 14, 2021 · 3 comments · Fixed by #258
Labels
enhancement New feature or request

Comments

@shayanhabibi
Copy link

shayanhabibi commented Sep 14, 2021

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

@alaviss alaviss added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Sep 14, 2021
@alaviss alaviss changed the title Unable to overload Voodoo/Magic calls Unable to overload voodoo/magic by continuation types Sep 14, 2021
@alaviss
Copy link
Contributor

alaviss commented Sep 14, 2021

The main limitation for this is that we have to produce a version of magic/voodoo without the continuation parameter so that it can be matched by sigmatch before {.cps.} kicks in.

I can only think of two ways out:

  • Figure out how to create these continuation-less wrappers in a shadow scope then inject them into cps body in an untyped pass (see this union PR which have something like that)
  • Get cps in the compiler and we can use its scoping system.

This issue is low priority for now.

disruptek added a commit that referenced this issue Nov 7, 2021
@disruptek disruptek linked a pull request Nov 7, 2021 that will close this issue
disruptek added a commit that referenced this issue Nov 7, 2021
@alaviss
Copy link
Contributor

alaviss commented Nov 10, 2021

#258 was reverted

@alaviss alaviss reopened this Nov 10, 2021
@alaviss
Copy link
Contributor

alaviss commented Nov 10, 2021

Future fixes to this bug needs to be aware of #259.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants