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

[TODO] [WIP] new outplace operator without intermediate copies/temporaries #13337

Closed

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Feb 5, 2020

Not ready for review unless you want to help (eg concrete simpler implementation suggestion etc), but this seems to work well

Will eventually merge this into #13309, just a preview.
Implementation is more complex, which is the price to pay for generating efficient code: this avoids temporaries where possible; namely: consecutive elements in a .> chain generate a single temporary instead of 1 per element of the chain.

example:

@[1].>fun(2).>fun(3).process.process.>fun(4).>fun(5)

generates:

block:
  var tmp_475204 = @[1]
  fun(tmp_475204, 2)
  fun(tmp_475204, 3)
  var tmp_475205 = tmp_475204.process.process
  fun(tmp_475205, 4)
  fun(tmp_475205, 5)
  tmp_475205

more examples: see unittests

still open questions

  • we could in fact avoid any copies at all in some cases (eg when leftmost expression in a chain is a nnkIdent), but that currently breaks for examples involving openArray, see D20200205T024841 in tests

@timotheecour
Copy link
Member Author

Out of curiosity, does it still need to be called "outplaces" instead of just "outplace"?

replied here: #13309 (comment) ; no need to duplicate comments ;-)

@timotheecour timotheecour force-pushed the pr_outplace_operator_nocopy branch from 2893636 to c55aad8 Compare February 9, 2020 08:38
@Araq
Copy link
Member

Araq commented Feb 12, 2020

See nim-lang/RFCs#192 for a discussion of the design.

@Araq
Copy link
Member

Araq commented Apr 20, 2020

RFC is shipping.

@Araq Araq closed this Apr 20, 2020
@timotheecour timotheecour changed the title [WIP] new outplace operator without intermediate copies/temporaries [TODO] [WIP] new outplace operator without intermediate copies/temporaries Jul 28, 2020
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 this pull request may close these issues.

2 participants