GithubHelp home page GithubHelp logo

Comments (2)

beef331 avatar beef331 commented on July 30, 2024

Issue seems to be sink tuple drops sink afaik so you probably want:

type
  A = object
  B = object
  C = object
  
proc foo[A, B, C: tuple](input: sink A; adding: sink B; output: var C) =
  output = (input[0], adding[0], adding[1])

let combine = foo[(A,), (B, C), (A, B, C)]
echo typeof(combine)

from nim.

Nycto avatar Nycto commented on July 30, 2024

Unfortunately, it doesn't look like that will work for my specific use case. I had simplified my code for the sake of repro, but what I'm doing is passing the proc reference to a function, more like this:

type
  A = object
  B = object
  C = object
  
proc foo[X, Y, Z: tuple](input: sink X; adding: sink Y; output: var Z) =
  output = (input[0], adding[0], adding[1])

proc useFoo(fooArg: proc (existing: sink (A, ), newValues: sink (B, C), output: var (A, B, C)) {.nimcall.}) =
  discard

useFoo(foo)

This still fails:

/usercode/in.nim(12, 7) Error: type mismatch
Expression: useFoo(foo)
  [1] foo: proc (input: sink X: tuple, adding: sink Y: tuple, output: var Z: tuple)

Expected one of (first mismatch at [position]):
[1] proc useFoo(fooArg: proc (existing: sink (A,); newValues: sink (B, C);
                          output: var (A, B, C)) {.nimcall.})
  expression 'foo' is of type: proc (input: sink X: tuple, adding: sink Y: tuple, output: var Z: tuple)

from nim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.