Nim icon indicating copy to clipboard operation
Nim copied to clipboard

`import` now works at local scope

Open timotheecour opened this issue 3 years ago • 7 comments

links

  • see tests
  • see RFC: fixes https://github.com/nim-lang/RFCs/issues/410
  • https://www.pythoninsight.com/2018/09/why-doesnt-import-work-at-function-scope/

there’s an exception for “from ... import *“, which can’t be used inside a function

timotheecour avatar Aug 23 '21 07:08 timotheecour

Why not just allow general imports at local scope?

konsumlamm avatar Aug 23 '21 10:08 konsumlamm

Why not just allow general imports at local scope?

done

timotheecour avatar Aug 23 '21 18:08 timotheecour

This would be very useful! Does this require an RFC? I don't think it is controversial, but still.

konsumlamm avatar Aug 23 '21 18:08 konsumlamm

This would be very useful! Does this require an RFC? I don't think it is controversial, but still.

see https://github.com/nim-lang/RFCs/issues/410

and yes, this is very useful.

timotheecour avatar Aug 23 '21 18:08 timotheecour

Add a line explaining that import is scoped in the Manual near https://nim-lang.github.io/Nim/manual.html#modules-import-statement

juancarlospaco avatar Aug 24 '21 19:08 juancarlospaco

Add a line explaining that import is scoped in the Manual near

done, i added a section

timotheecour avatar Aug 24 '21 20:08 timotheecour

This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions.

stale[bot] avatar Sep 08 '22 23:09 stale[bot]