Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Gregory Morrisett" <jgm@CS.Cornell.EDU>
To: "Paul Stodghill" <stodghil@CS.Cornell.EDU>,
	"Caml Mailing List (E-mail)" <caml-list@inria.fr>
Subject: RE: [Caml-list] Naming conventions
Date: Wed, 8 May 2002 09:31:57 -0400	[thread overview]
Message-ID: <706871B20764CD449DB0E8E3D81C4D4301EE6D38@opus.cs.cornell.edu> (raw)

> In Scheme, there is a conventtion that the names of 
> destructive functions end with "!" and predicates end with 
> "?". E.g., "append!" vs. "append", and "null?", "pair?", etc.
> 
> 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?) 

I tend to use imp_<id> (as in imp_push) to reflect the fact that 
something imperative is going on, and is_<id> for predicates
(as in is_empty).  

-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


             reply	other threads:[~2002-05-08 13:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-08 13:31 Gregory Morrisett [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-05-08 13:33 Krishnaswami, Neel
2002-05-08 13:59 ` Dave Mason
2002-05-08 17:12   ` Pierre Weis
2002-05-08 13:10 Paul Stodghill
2002-05-08 14:04 ` Ken Wakita

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=706871B20764CD449DB0E8E3D81C4D4301EE6D38@opus.cs.cornell.edu \
    --to=jgm@cs.cornell.edu \
    --cc=caml-list@inria.fr \
    --cc=stodghil@CS.Cornell.EDU \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox