-
Notifications
You must be signed in to change notification settings - Fork 23
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
RFC: move file I/O out of system.nim
#67
Comments
Adding to the complexity of file-handling in general are sandboxed platforms that define more extreme limitations on what you can do with File I/O, like macOS App Sandbox, UWP (which admittedly Nim does not support), etc. |
We might as well bite the bullet then and deprecate And import std / [sysio, gc, integerops, assertions]
export sysio, gc, integerops, assertions (Ideally, in practice it will be much messier...) |
There is already |
It doesn't really do that, you can still do |
+1 for I'd be careful however to ensure that there exists a
There's two ways to approach this - either burn current |
finally, I think the fact that large parts of the language are defined in |
The problem is though that even moving IO out of |
I'd think it can be done with a if done though, perhaps it's more interesting to do actually, #5698 is related which would help isolate os dependencies as well, in a different way. |
How so? "writeLine is deprecated, import io.nim to get a nice ambiguity error instead..." |
the biggest issue would be a few well-known names like In fact, a lot of what this feature is about "almost" exists today, as |
There has been made signification progress on this RFC and system.nim now delegates to |
is this Fixed now ❔ 🤔 |
it's still indirectly in |
update: see nim-lang/Nim#19442 |
for reference, we're using alternative I/O module in many of our projects: https://github.com/status-im/nim-stew/blob/master/stew/io2.nim - this might be a useful reference in the future. It covers some needs that arise when writing secure applications:
|
I like the Personally, I think Besides not breaking the world, it is much more general than just file IO. system/**.nim is currently a whopping 77 files -- roughly 25% of what is under Answering those questions might be hard. There can be gradual work to make Anyway, the That's about all I have to say. Maybe Araq's thought of something even better in the interrim. |
Since then I'm considering an even more drastic solution: To get
|
I am unsure if Though I am certain Araq knows, it bears mentioning that Also, the nim compiler has had There could be other mechanisms I'm forgetting... |
As long as edit: |
While I definitely see the advantage of cleaning up |
Both these comments connect to what I meant by "how much system/ relies upon the compiler (and how it relies)". Some stuff relies heavily on magics while other stuff does not. A "BS" grep measurement suggests there are 5x more '^proc' than "magic" in Re: @Vindaar's, it is surely true that re-implementing Writing an alternative (maybe radically trimmed down) system with the same magics available (but maybe not used) should kind of be the "imagined use case", even if the real motivation is "v2 system" vs "v1 system". { They are similar if you think about it. Also, someday there may even be v3. :-) }. Part of system/ being well factored might be that a "re-implementation" can be simply a piecing together of very small parts "a la carte"..a subset without the Re @konsumlamm's point, the stock And, yeah, yeah, maybe this config idea does not go as far as Araq would prefer or maybe I am just brainstorming compromises/directions to move the work along since @xflywind recently began work on separation. Resolving direction on this could maybe inform that work. |
It's hard but possible. You need to copy&paste the magics, yes, but sometimes you don't need all of them. Some magics are also magics for legacy reasons and could have easily been ordinary .inline procs or templates. And with Arc/Orc how the barebones runtime interacts with the compiler has been refined. |
That's true but not really meaningful as a module typically has other dependencies too like tables or strutils and these are not auto-imported either. In practice the difference is pretty much between import std / [strformat, tables]
and import std / [system, strformat, tables]
And if you prefer |
With |
The thing is modules like As it is currently, even if Another module that uses magics (and should be part of the spec) but is messy is If you had a standard library module just for macro convenience, you could add as much as you want without problems. There are a few modules in But there is a problem with these as well, being that they are too small. If the standard library is meant to be substituted by better user code, then there is no harm in these modules being as big or comprehensive as possible unlike My point is |
I agree that system replacement (even by a la carte selection/re-composition) will be/should be more rare/special/careful. Being possible remains valuable and the right mental model, though. Re: moving "convenience" macro stuff, It's a complex, but important question interacting with people's workflows where consensus is often hard to get and also relates to "modules vs packages" (or maybe |
One thing we do very consistently is to re-export anything that a module requires to work - for example, if a module exposes a public API that returns a Once you start doing this, imports and exports become a manageable problem - of course, the single global namespace is another major obstacle to productivity in library development, but this way, at least it's humanly possible to reuse a simple one. If this is adopted by the std library itself, it would effectively mean that most std modules would re-export the version of system that they depend on, and the damage will be limited - most std modules use However, it would provide many of the benefits still: modules that start with a clean slate would be explicit about their dependencies and this is really the only way out here: being explicit opens the path for many other future cleanups, as well as "specialized" std libraries such as those that are needed for WASM, controllers, etc. |
In Rust and Haskell "no-std" and "no-prelude" are quite popular or at least they are vocal. Also this opens the path to a "sys-noalloc" library where allocations are heavily discouraged (embedded, cryptography, GPUs, ...) and "sys-convenience" where you have access to seqs/strings and stuff like that. But then there is the danger of too much granularity. |
In line with Nim being a systems-level programming language, it makes sense that
system.nim
cover only a minimal set of language-specific features and leave interactions with the outside world to other modules, so as to separate concerns cleanly and ensure that a stable core of the language can be used and depended upon from a broad set of platforms.It's also been commonly noted that
system.nim
has grown uncomfortably large as more and more features are added to it.Thus I'd like to propose all things file be moved to a separate module that must be explicitly imported.
system.nim
The text was updated successfully, but these errors were encountered: