neo icon indicating copy to clipboard operation
neo copied to clipboard

Error: undeclared identifier: 'shallowCopy'`` on all examples

Open general-rishkin opened this issue 2 years ago • 5 comments

All the examples I try give the following error:

neo/dense.nim(90, 14) Error: undeclared identifier: 'shallowCopy'

I am using Nim Compiler Version 1.9.1 .

general-rishkin avatar Jan 24 '23 23:01 general-rishkin

See this PR. The issue is: shallowCopy was kind of needed to have matrices that share storage (think of taking a row, or the transpose of a matrix, without making copies). So I have not accepted the PR yet.

I can probably work arund this with the shallow pragma, but it would take a while... I am no actively using Nim right now, so this kind of language level change is rather disruptive. If you want to start from that PR and ensure that copies are actually shallow, I would be happy to accept it

andreaferretti avatar Apr 04 '23 13:04 andreaferretti

As someone who has the same problem, an easy solucion is write --gc:refc as option, something like nim c --gc:refc -r main.nim PD: you can use this command nim c --mm:refc -r main.nim too

NahuelUTNPigui avatar May 17 '24 22:05 NahuelUTNPigui

How feasible would it be for a Nim newcomer to implement the shallow pragma workaround? I'm hoping to use Nim for a WebAssembly project, which doesn't seem compatible with --gc:refc.

Vectornaut avatar Jul 23 '24 20:07 Vectornaut

It would amount to marking data as shallow in places like here and here, and similarly in cudadense etc, then removing shallowCopy where it appears, running tests and checking what breaks. When something breaks, it will be probably because there was an implicit copy of data somewhere; in thit case, make the copy explicit.

Test coverage is good enough that I think if tests pass, everything is fine.

andreaferretti avatar Jul 24 '24 07:07 andreaferretti

Thanks so much! That doesn't sound as difficult as I'd feared. If we end up considering Nim seriously enough to put some work into this issue, I'll let you know.

Vectornaut avatar Jul 25 '24 09:07 Vectornaut