QM has asked for the wisdom of the Perl Monks concerning the following question:
mkdir FILENAME
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: mkdir in perldoc
by marto (Cardinal) on Jan 09, 2013 at 10:16 UTC | |
Everything_is_a_file, if you feel strongly about changing this consider raising the issue with the maintainers. | [reply] |
by QM (Parson) on Jan 09, 2013 at 11:41 UTC | |
Everything is a file...Yes, but in the documentation filename is used 2 ways, first as a standin for the wordy "file system entity", and second as an ordinary file (not a directory or somesuch). But since its use in mkdir is not the generic file system entity, it's misleading. (I'm particularly amused by rmdir's description.) -QM | [reply] |
by marto (Cardinal) on Jan 09, 2013 at 11:53 UTC | |
The entries in mkdir and rmdir state: "Creates the directory specified by FILENAME" "Deletes the directory specified by FILENAME if that directory is empty." Now the Microsoft documentation states: "Note that a directory is simply a file with a special attribute designating it as a directory, but otherwise must follow all the same naming rules as a regular file. Because the term directory simply refers to a special type of file as far as the file system is concerned, some reference material will use the general term file to encompass both concepts of directories and data files as such." I don't find any of this misleading. If you do feel free to make a case to improve the documentation in question to those who maintain it. | [reply] |
Re: mkdir in perldoc
by blue_cowdawg (Monsignor) on Jan 09, 2013 at 14:10 UTC | |
Given that (and I could be wrong here) Perl was first developed on Unix and Unix takes the view that files and directories are the same thing I'm not surprised. A directory on *nix is just a file of I-Node pointers with file names as the index key. (an oversimplified explanation I realize) Peter L. Berghold -- Unix Professional Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg | [reply] |
Re: mkdir in perldoc
by jkeenan1 (Deacon) on Jan 09, 2013 at 03:20 UTC | |
Jim Keenan
| [reply] [d/l] [select] |
by Anonymous Monk on Jan 09, 2013 at 03:35 UTC | |
Perhaps we should ask Larry? Let's not | [reply] |
Re: mkdir in perldoc
by 7stud (Deacon) on Jan 09, 2013 at 10:08 UTC | |
| [reply] |
by QM (Parson) on Jan 09, 2013 at 10:52 UTC | |
Perhaps because the names of files and directories are generically known as "filenames" in the unix world.:D Not knocking you for this, but it's equivalent to Anonymous Monk's "Because", perhaps funneling into Appeal_to_tradition. But seriously, I understand, "FILENAME" here may be a generic term for any named filesystem entry, whether it's a file, link, directory, device, pipe, etc. But mkdir will only make directories, so let's be clear and specific, when that doesn't compromise generality. "mkdir DIRNAME" will in no way cause anyone to misunderstand what will happen. On the other hand, if there's some great savings in coding so docs and parsers and grammars don't have to handle special cases between things like chdir, mkdir, open, do, require, rmdir, chroot, link, symlink, and other things that take named filesystem entities, I'm all ears. I'm sure the developers have enough to do besides handle pedantic observations like this. Whoops! See rmdir: rmdir FILENAME rmdir Deletes the directory specified by FILENAME if that directory is empty. If it succeeds it returns true; otherwise it returns false and sets $! (errno). If FILENAME is omitted, uses $_ . To remove a directory tree recursively (rm -rf on Unix) look at the rmtree function of the File::Path module. And chmod and chown look weird, just specifying a list. For example: chmod LISTwhen the detail says the first element must be the mode. This is better written as: chmod MODE, LIST -QM | [reply] [d/l] [select] |
by tye (Sage) on Jan 09, 2013 at 23:40 UTC | |
Actually, the terse syntax examples given in the Perl documentation convey subtle meaning to those who are aware of the conventions being used and changing "chmod LIST" to "chmod MODE,LIST" would convey incorrect information to such people. (To become such a person, in part, one just needs to read, understand, and remember the 2nd paragraph of perlfunc.)
I don't mind being told "mkdir FILENAME" because it hints at this possibility:
I started down the road of proposing that one of those conventions might actually be involved in the choice of "FILENAME" over "DIRNAME", because I noticed this:
But that doesn't make sense for a lot of reasons. I also noticed:
So, how does opendir describe its argument?
Now, that needs to say "DIRHANDLE" and not "FILEHANDLE", because you can't use a Perl DIRHANDLE as a Perl FILEHANDLE so that distinction is rather important. There is no such distinction between a FILENAME and a DIRNAME for Perl (nor for Unix, nor for Windows). But why is that "EXPR" and not "FILENAME"? Well, it is a common choice:
One could argue that "do EXPR" helps to convey the point that "any (other) expression gets interpretted as a file name" as opposed to possibly implying that Perl does something like looking at the value to see if it looks like a file name.
And that might explain the choice of "EXPR" for these cases as well:
Though, I think the case of noticing FILEHANDLE and DIRHANDLE exceptions really is about examining the value not about different syntax, so I find the "EXPR" choice less valuable here. But changing "stat EXPR" to "stat FILENAME" draws too much attention to the distinction between "FILE" and "DIR" in:
While I think changing "DBNAME" to "FILENAME" would significantly improve the clarity here:
(Because "DBNAME" isn't a "FILENAME" in most contexts I deal with -- though, perhaps "FILENAME" was avoided since suffixes likely get appended.) How about places that don't use "EXPR"?
I find "OLDNAME" a much better choice than "OLDFILE". Similar to the starting complaint, "OLDFILE" could be the name of a directory. But more important, for me, is that "OLDFILE" doesn't as clearly convey that what is given is the name of a file not some handle or other representation. I also wouldn't go more explicit like these:
because I would worry about implying that these can't be used on directories [which isn't something I worry about implying for mkdir() or rmdir()]. One could argue for:
but I'd probably depart even further and go with:
(I've long found the argument order for link,3 and ln quite confusing, I must admit.) After considering the broader context, I think most of the uses of "FILENAME" really should be changed to "DIRNAME". Not because I find those uses of "FILENAME" confusing or inappropriate, but because they are cases where the distinction doesn't matter and so "DIRNAME" is just slightly clearer. (I find many cases that are a lot more in need of improvement than the one that started this thread.) Contrast that with changing "lstat EXPR" to "lstat FILENAME". I don't like "lstat FILENAME" as it sounds like it might be trying to imply that you can't use it on directories or links, but only on plain files. But I also see no reason to use "EXPR" for that case. I think I prefer "lstat PATHNAME". So my updates would only be as follows: Read more... (1442 Bytes) So I'd explicitly leave these unchanged:
- tye | [reply] [d/l] [select] |
by QM (Parson) on Jan 10, 2013 at 09:30 UTC | |
by tye (Sage) on Jan 10, 2013 at 16:14 UTC | |
by Anonymous Monk on Jan 10, 2013 at 09:38 UTC | |
Re: mkdir in perldoc
by Anonymous Monk on Jan 09, 2013 at 03:14 UTC | |
Because :) | [reply] |