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

Problem with the create* API of synchronization primitives #75

Open
planetis-m opened this issue Aug 18, 2024 · 2 comments · May be fixed by nim-lang/Nim#24327
Open

Problem with the create* API of synchronization primitives #75

planetis-m opened this issue Aug 18, 2024 · 2 comments · May be fixed by nim-lang/Nim#24327

Comments

@planetis-m
Copy link
Contributor

The following code gives the error message: Error: '=sink' is not available for type <Semaphore>; routine: main

const
  N = 2

var
  arrived: array[N, Semaphore]

proc main =
  for i in 0 ..< N:
    arrived[i] = createSemaphore()
main()
@planetis-m
Copy link
Contributor Author

However if we used:

proc init*(s: out Semaphore; count = 0) =
  s.counter = count
  initCond(s.c)
  initLock(s.L)

That wouldn't be an issue.

@planetis-m
Copy link
Contributor Author

planetis-m commented Aug 20, 2024

From the chat

you cannot "move" a pthread mutex but Nim's notion of a move is different from the idea "tied to its stack location"

disabling =sink is an ABI problem but we don't want semantic checking to depend on the ABI. We need to teach the code generator that a disabled =sink means "pass by pointer"

or we keep using .byref

ok so remove =sink .error?

patch the compiler so that let x = f() works for type T if T is byref

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

Successfully merging a pull request may close this issue.

1 participant