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 PAA31039; Wed, 8 May 2002 15:31:59 +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 PAA31021 for ; Wed, 8 May 2002 15:31:58 +0200 (MET DST) Received: from exchange.cs.cornell.edu (exchange.cs.cornell.edu [128.84.97.8]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g48DVvD22574 for ; Wed, 8 May 2002 15:31:57 +0200 (MET DST) content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable Subject: RE: [Caml-list] Naming conventions X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 Date: Wed, 8 May 2002 09:31:57 -0400 Message-ID: <706871B20764CD449DB0E8E3D81C4D4301EE6D38@opus.cs.cornell.edu> Thread-Topic: Naming conventions Thread-Index: AcH2kcgUH8bnThBaQjOafGZDS/igxQAAdorg From: "Gregory Morrisett" To: "Paul Stodghill" , "Caml Mailing List (E-mail)" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > In Scheme, there is a conventtion that the names of=20 > destructive functions end with "!" and predicates end with=20 > "?". E.g., "append!" vs. "append", and "null?", "pair?", etc. >=20 > Are there any similar conventions that people use in O'Caml? I don't think there's a convention. Part of the reason is that it tends to be manifest in the type whether or not an operation is destructive and whether or not it is a predicate. Consider: val push : 'a -> 'a stack -> 'a stack (* functional *) versus val push : 'a -> 'a stack -> unit (* imperative *) That's not to say that it wouldn't be good to have a convention, especially when something has an interface that looks functional but does some observable side effect. Furthermore, it's often hard to tell constructors from predicates when reading code (i.e., does "empty" construct an empty stack or is it a predicate that returns true on an empty stack?)=20 I tend to use imp_ (as in imp_push) to reflect the fact that=20 something imperative is going on, and is_ for predicates (as in is_empty). =20 -Greg ------------------- 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