Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Unix.chmod => what codes for what mode?!
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Matt Gushee <mgushee@h...>
Subject: Re: [Caml-list] Unix.chmod => what codes for what mode?!
On Fri, Apr 23, 2004 at 07:01:02PM +0100, Richard Jones wrote:
> On Fri, Apr 23, 2004 at 07:16:34PM +0200, Oliver Bandel wrote:
> > 
> > The Unix.chmod function is bad documented.

I agree. See below.

> Almost certainly you're not using octal numbers right.  The format
> for octal numbers in OCaml is different from C, for example:

My guess would be that he simply wasn't conscious of the fact that they
*were* octal numbers--which is the same mistake I made at first and have
seen several others make. The fact that permissions are octal is easy to
understand, but--if you have worked with file permissions in the Unix 
shell and never either worked with them in a medium level language like
C or thought deeply about what the numbers represent, it's not at all
obvious. After all, in the following:

> % chmod 755 filename

755 just looks like an integer, doesn't it?

Hence the documentation issue. I also suggested, when I ran into this
problem, that the fact these are octal numbers should be documented. I
was told that it is documented, in ... I forget where, but someplace
rather distant from the Unix API doc. I submit that that is inadequate
documentation for many people.

Of course, it's often very difficult to tell how thoroughly and
explicitly to document a language. And the very best programmers, and
those most familiar with the system, often produce documentation that is
both thorough and correct, but at the same time horribly obscure for
mere mortals. Actually, I think the OCaml team does pretty well,
considering the inherent difficulty of the language and the small amount
of time they can devote to documentation. Still, it could be better.

It often seems that, when people raise concerns like this about the
OCaml documentation, they get responses that, while well-intentioned and
courteous, imply that it is their fault for not having read the right
document or for lacking the necessary background (BTW, I'm not pointing
at anyone in this particular discussion), and that's a shame.

I'm reminded of the old parables of Jesus (or the Buddha) knocking on
people's doors disguised as a beggar: the "dummy" you alienate with an
unhelpful answer might turn out to have been a high school student who
could have become a brilliant OCaml programmer, or perhaps a senior
system architect who no longer programs very much--but might be in a
position to influence the CTO of a large corporation.

Not that we should try to make OCaml understandable to the entire
world--that would be absurd. But when a small effort would make it
easier for a significant number of people, why not? E.g.:

  Note that [permissions] is an octal number. Example:

    Unix.chmod 0o755 myfile

There. That took about 30 seconds.

-- 
Matt Gushee                 When a nation follows the Way,
Englewood, Colorado, USA    Horses bear manure through
mgushee@havenrock.com           its fields;
http://www.havenrock.com/   When a nation ignores the Way,
                            Horses bear soldiers through
                                its streets.
                                
                            --Lao Tzu (Peter Merel, trans.)

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners