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

add typesafe std/paths, std/files, std/dirs, std/symlinks #20582

Merged
merged 16 commits into from
Oct 21, 2022
Merged

add typesafe std/paths, std/files, std/dirs, std/symlinks #20582

merged 16 commits into from
Oct 21, 2022

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Oct 17, 2022

Ref nim-lang/RFCs#437
fixes nim-lang/RFCs#54
fixes nim-lang/RFCs#71

Now Path is defined as distinct string, refined functions should be based on this signature.

  • documentaion
  • tests

todo in the following PRs

  • copyFile, copyDir
  • createFile
  • runnableExamples
  • documentaion links
  • std/appdirs

@ringabout ringabout changed the title split std/os; add typesafe std/paths split std/os; add typesafe std/paths Oct 17, 2022
@ringabout ringabout changed the title split std/os; add typesafe std/paths split std/os; add typesafe std/paths, std/files, std/dirs Oct 17, 2022
@juancarlospaco

This comment was marked as outdated.

@Araq
Copy link
Member

Araq commented Oct 18, 2022

Now Path is defined as distinct string, refined functions should be based on this signature.

Agreed. In the past I've argued for even more fine-grained distinctions like AbsolutePath vs AbsoluteFile and Relative variants but I changed my mind. A single Path type is good enough and slightly easier to work with.

@beef331
Copy link
Collaborator

beef331 commented Oct 19, 2022

With the new Os/Io implementation, will the nimscript operations be moved to another module so that we can use things like fileExists of the host machine at compile time when targeting an OS that doesnt support it?

@ringabout ringabout changed the title split std/os; add typesafe std/paths, std/files, std/dirs add typesafe std/paths, std/files, std/dirs Oct 19, 2022
@Araq
Copy link
Member

Araq commented Oct 19, 2022

With the new Os/Io implementation, will the nimscript operations be moved to another module so that we can use things like fileExists of the host machine at compile time when targeting an OS that doesnt support it?

There are no plans wrt compile-time evaluation for os.nim. Everything we change or add needs an RFC to justify it because it's so easy to get this wrong.

@ringabout ringabout changed the title add typesafe std/paths, std/files, std/dirs add typesafe std/paths, std/files, std/dirs, std/symlinks Oct 20, 2022
@ringabout ringabout mentioned this pull request Oct 20, 2022
33 tasks
@ringabout ringabout marked this pull request as ready for review October 21, 2022 12:49
@ringabout
Copy link
Member Author

This PR doesn't contain any API addition, which will be added later. std/files, std/dirs and std/symlinks contain minimal APIs.

@Araq
Copy link
Member

Araq commented Oct 21, 2022

@ringabout So ... is it ready to review?

@ringabout
Copy link
Member Author

Yes

lib/std/paths.nim Outdated Show resolved Hide resolved
lib/std/paths.nim Outdated Show resolved Hide resolved
lib/std/paths.nim Outdated Show resolved Hide resolved
lib/std/paths.nim Outdated Show resolved Hide resolved
lib/std/paths.nim Outdated Show resolved Hide resolved
lib/std/paths.nim Outdated Show resolved Hide resolved
lib/std/paths.nim Outdated Show resolved Hide resolved
lib/std/paths.nim Outdated Show resolved Hide resolved
@ringabout ringabout requested a review from Araq October 21, 2022 17:52
@Araq Araq merged commit 3c12b72 into devel Oct 21, 2022
@Araq Araq deleted the pr_path branch October 21, 2022 19:53
@github-actions
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from 3c12b72

Hint: mm: orc; opt: speed; options: -d:release
163589 lines; 8.013s; 613.695MiB peakmem

capocasa pushed a commit to capocasa/Nim that referenced this pull request Mar 31, 2023
…m-lang#20582)

* split std/os; add typesafe std/paths
* add more files, dirs, paths
* add documentation
* add testcase
* remove tryRemoveFile
* clean up
* Delete test.nim
* apply changes
* add `add` and fixes
bung87 pushed a commit to bung87/Nim that referenced this pull request Jul 29, 2023
…m-lang#20582)

* split std/os; add typesafe std/paths
* add more files, dirs, paths
* add documentation
* add testcase
* remove tryRemoveFile
* clean up
* Delete test.nim
* apply changes
* add `add` and fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants