From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA17035; Sun, 22 Jul 2001 12:06:23 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA17043 for ; Sun, 22 Jul 2001 12:06:22 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f6MA65b02752; Sun, 22 Jul 2001 12:06:05 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA17045; Sun, 22 Jul 2001 12:06:05 +0200 (MET DST) From: Pierre Weis Message-Id: <200107221006.MAA17045@pauillac.inria.fr> Subject: Re: [Caml-list] indent 2 In-Reply-To: from Brian Rogoff at "Jul 21, 101 11:07:51 am" To: bpr@best.com (Brian Rogoff) Date: Sun, 22 Jul 2001 12:06:05 +0200 (MET DST) Cc: avv@quasar.ipa.nw.ru, Damien.Doligez@inria.fr, bpr@best.com, caml-list@inria.fr X-Mailer: ELM [version 2.4ME+ PL28 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > No idea why I was specifically addressed for this, but since you ask... > > On Sat, 21 Jul 2001, Alexander V. Voinov wrote: > > Hi Damien, > > > > Damien Doligez wrote: > > > > > > >From: "Alexander V. Voinov" > > > > > > >Is the indentation with the step 2 a _must_ for those who program in > > > >OCaml? I got used 4, and already set all the necessary variables for > > > > > > Hey, the Soviet Union doesn't exist any more. Welcome to the free > > > world, comrade. > > > > Oh, if it were that simple. The pressure of the society may be much > > stronger than the pressure of an external authority, which contrasts > > itself to the society. Because the former penetrates deeper into one's > > mentality. (Sorry for offtopic) > > That's too deep for me, I'm just an American. I can't resist to cite this slogan that I learnt long time ago from the chinese communists (I really do not remember if it were about Caml programming guidelines or not): Always follow the party's line, but don't be afraid to swim against the main stream. [...] > It seems that the Caml community mostly indents by two spaces, so if > you'd like to be a good neighbor you should do so as well. No one will > shun you if you refuse and use four spaces, and your code will still > be readable. Well, OK, I'll shun you, but probably noone else :-). I will shun you also, but probably nobody else. Oh yes, now I remember, for indentation the chinese slogan was: Consistenly use one or two extra spaces when indenting, but fill free to indent as you like it. (Sorry for not being so serious about that (in fact) important subject.) More seriously: Caml is a language of expressions (not blocks of instructions), and expressions tend to nest rather deeply. Hence it is not uncommon to have indentation level growing up to 5 in a regular program (in some bad cases it could go up to 10). Then suppose you use 4 spaces as indentation: 10 times 4 is 40 and the left margin is in the middle of the page. That's way too much. That's why people use 2 spaces since 20 spaces in the left margin is ok. Personnaly, I use one space with some exceptions for 2 spaces indentation (which is inconsistent, I know it!) for reasons that are explained in the Caml programming guidelines. (In short, I write 2 spaces to align the |'s in the pattern matchings of function definitions: let rec length = function | [] -> | x :: l -> but I write one space to indent within an arithmetic expression, if then else, applications ..., no space at all (or alignment to the keyword) for pattern matching clauses of try and match.) However, I use these rules consistently and have made the effort to write them out with pro and cons arguments, so that you can read those and design your own consistent set of rules. Kidding again: evidently, the best you can do is to choose your set of rules so that it appears to be exactly ours (a variation on the chinese slogan for indentation :) > Its wise to invest some time reading the compiler sources. I wish I had > done so earlier. Absolutely. > -- Brian > > PS: It would be useful to have the programming guidelines extended to > cover programming with classes and modules. I added some paragraph on modules. May be you can tell me what topics I have to add or extend about modules ? For classes, I'm a bit more puzzled and I need help from people that use classes more than I do, and that already know what are the problems to avoid and the styles to recommend. Waiting for your helpful comments and suggestions, Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/ ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr