-
Notifications
You must be signed in to change notification settings - Fork 10
Add Filesystem\unlink(), and similar operations that aren't related to handles #29
Comments
Current thinking:
|
agree
agree
how would the
an abstraction, let's keep see : https://github.com/nuxed/filesystem
silent
agree, IMHO i don't think |
I don't like the distinction between File and Filesystem, why not
I don't know -- in general I don't think we should hide potentially expensive operations that can fail inside what looks like a getter method, but I don't know if there's a better option here. It might be OK depending on the exact API (e.g. if it clearly doesn't look like a getter method). If possible, I would maybe try to do the opposite: Have a function that clearly looks like an expensive operation that can fail, but sometimes it returns a value without actually doing the operation if the value is somehow already available. I am starting to be a bit confused about the namespaces, OS vs IO vs File/TCP/etc. I'm not sure if it makes sense to simplify that or if that's necessary, but some random ideas: Would it be crazy to merge OS and IO? We already settled on (I think) doing that for exceptions. Are there any OS operations that could not be reasonably described as IO? If not, then IO might be the preferable name, it seems more common than OS. As a user of the language, I would really rather not end up in a situation where there are 4 different namespaces in which a function like "unlink" could reasonably exist (OS, IO, Filesystem, File). |
Well-typed common subset of (macos & linux)
That'd probably be the best for user expectations, but it does mean that we'd have non-OS-defined functions in OS; not sure that's right
While I agree with the conclusion, and while current usage must be covered adequately, we are very definitely targeting the long-term goals with this design, even if it ends up having some negative effects for current uses.
Very strongly against this - it is necessary to leak this particular one as "I accidentally called
Not crazy - though I feel that in a way OS\ is more well-defined: thin wrappers. I'd expect IO functions in OS\ to be a thinner layer over FDs, and not to provide functions like Perhaps that idea of Also, if OS\ will contain non-IO stuff, it would be good to keep the mess of IO\ interfaces out of there for readability.
Python's OS module seems pretty much the same thing (low-level wrappers of POSIX stuff); some examples:
There's some debatable cases like getcwd, exec, fork, kill
Definitely agree. Unless we merge IO\ and OS, I think it'd be good to strongly discourage using the stuff in OS\ except where necessary - but recognize it is necessary for completeness. Quoting myself here:
This isn't necessarily true if we ship C FFI - but the HSL won't be able to use that, and we should expect other deployments to disable it in libraries out of security concerns |
That sounds reasonable to me. What would be the disadvantages? Are there legitimate use-cases for people using low-level functions for anything where we provide a higher-level abstraction? (e.g. performance?)
I think I'd rather have a few slightly strange-feeling functions like this, than a library where people have to remember which functions are in File vs Filesystem based on how strange each one felt to the library authors :) |
Depends on if we tradeoff usability for completeness; for example, PHP and OCaml's Also, if we want to be able to cover systems programming, we probably need to expose the POSIX-like behaviors (and there are non-technical restrictions on what we can name that namespace which is why errno is in OS); they're very specifically defined in annoying ways, but sometimes you need that (e.g. I needed that when implementing async socket connections); I think if we aim to be sufficiently complete in a higher-level abstraction, we're going to fail, and have a lot of hard-to-debug problems.
Yeah... I need to figure out if there's an underlying reason that can be consistently applied, or if I'm just being weird about that :) |
Yeah I guess if one of the namespaces (OS?) is very explicitly for low-level things that almost no one needs, and anything that is not strictly equivalent to a low-level call goes to a different namespace, that seems pretty reasonable. "If you have to ask than this is not the namespace you want" is an easy enough rule for people to remember :) |
Does "almost no one ever handles |
So, are we leaning towards:
Okay, actually a little bit of bikeshedding about readdir: I could go a step thinner: using $dir = OS\opendir($path) {
while ($dirent = OS\readdir($dir)) {
// ...
}
} This would be very slightly better if you have a huge directory and want to exit early. IMO we should generally consider the 'returns each in turn then returns nullptr' C pattern to be 'the block as a whole returns a vec', and if there is a case where it turns out to matter, add both forms. |
Actually that's another case of my fuzzy feelings rather than consistent principle. Let's go for as thin as practical, and add the slightly-less-thin versions if needed after profiling. so, OS\opendir($path), OS\readdir($dir), add OS\readdir_vec($path) or something later if it turns out to actually be a problem. |
Sounds reasonable. Also eventually the OS namespace should probably be built-in, not part of HSL, right? We don't want wrappers like
in the long term (might be needed temporarily). |
IMO, |
IMO ideally the whole HSL should be built-in :)
I suspect what I'll end up doing to 'release' HSL IO is to add a new _Private\Native\FileDescriptor type, and add |
I meant "built-in" as in written in C++ with Hack code only in .hhi files. I don't think we need that for the whole HSL, but definitely the whole HSL should be "built-in" as in shipped with HHVM. |
I dream of a world where the PHP stdlib needs a runtime option to be available at all - and the HSL doesn't depend on it :) |
I dream of a world where the PHP stdlib is not available at all - and the HSL doesn't depend on it :)* |
i have implemented this in PSL, it is built in top of PHP stdlib, but could provide a reference for naming.. etc. https://github.com/azjezz/psl/tree/1.8.x/src/Psl/Filesystem |
No description provided.
The text was updated successfully, but these errors were encountered: