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

Prevent copying of Flowvar and Pending results #152

Open
mratsim opened this issue May 20, 2020 · 0 comments
Open

Prevent copying of Flowvar and Pending results #152

mratsim opened this issue May 20, 2020 · 0 comments
Labels

Comments

@mratsim
Copy link
Owner

mratsim commented May 20, 2020

Some assumptions of Weave is that there is a single consumer of a future result (Flowvar or Pending) and that it tried to consume that result only once.

While we can't prevent the latter at compile-time, we can prevent the first by only allowing the sink/move operation on the type and making copies a compile-time error:

type
  Flowvar[T] = object

proc `=`[T](dst: var Flowvar[T], src: Flowvar[T]) {.error: "copying not allowed".}

proc newFlowvar(T: typedesc): Flowvar[T] =
  discard

let x = newFlowvar(int)

However we get unresolved generic parameter at the moment due to upstream bug nim-lang/Nim#14315

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

No branches or pull requests

1 participant