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

Return var results when indexing #487

Open
cmacmackin opened this issue Jan 3, 2021 · 3 comments
Open

Return var results when indexing #487

cmacmackin opened this issue Jan 3, 2021 · 3 comments

Comments

@cmacmackin
Copy link

It would be handy to add indexing operators with return type var Tensor[T] so that the result can be passed to a function for in-place operations. This may relate to #52.

@Vindaar
Copy link
Collaborator

Vindaar commented Jan 4, 2021

@mratsim
Copy link
Owner

mratsim commented Jan 5, 2021

I'm all for it but every time I tried I had nasty bugs that surfaced in the test suite.
Some of which were corrupting the return data iirc.

In particular returning var seq[T] is broken and if var seq[T] doesn't work, there is no chance for var Tensor[T] to work
91850c5#diff-9827c41e5a724052d30ac0f444f15f465729f1116cdd2614a16f27fd3ad041c4R98

The workaround is to assign the result of indexing to a var first and pass that to the function.

@cmacmackin
Copy link
Author

@Vindaar When I tried using the [] operator in a place where a mutable result was needed I got a compiler-error because apparently it didn't return a mutable result.

@mratsim Is this due to some upstream bug with Nim?

Thanks for the workaround, I've been doing that. Reminds me of using Fortran...

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

No branches or pull requests

3 participants