caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dave Mason <dmason@sarg.ryerson.ca>
To: "Caml Mailing List (E-mail)" <caml-list@inria.fr>
Subject: Re: [Caml-list] Naming conventions
Date: Wed, 08 May 2002 09:59:23 -0400	[thread overview]
Message-ID: <200205081359.g48DxNO09861@sarg.ryerson.ca> (raw)
In-Reply-To: Your message of "Wed, 08 May 2002 09:33:03 EDT." <B1E4D3274D57D411BE8400D0B783FF32A8D754@exchange1.cswv.com>

For non-OO style Ocaml, I agree that the type signature is usually
enough, although I also often use is_foo or fooP as predicates.

But, the original question was about objects.  In Java there is a
style that is fairly convenient, whereby mutators for objects return
the object itself instead of void (unit).  This allows doing:

    let theLeftFoo = new foo(42) in
        theLeftFoo.setX(...)
                  .setY(...)
                  .initBar()

as opposed to:

    let theLeftFoo = new foo(42) in
	theLeftFoo.setX(...);
        theLeftFoo.setY(...);
        theLeftFoo.initBar();
        theLeftFoo

I am undecided whether I think this is a good style or not, but it is
more readable if you like to give meaningful (and hence long) variable
names.  (If I'd used x instead of theLeftFoo, you probably wouldn't
have noticed much difference.)

../Dave
-------------------
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 14:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-08 13:33 Krishnaswami, Neel
2002-05-08 13:59 ` Dave Mason [this message]
2002-05-08 17:12   ` Pierre Weis
  -- strict thread matches above, loose matches on Subject: below --
2002-05-08 13:31 Gregory Morrisett
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=200205081359.g48DxNO09861@sarg.ryerson.ca \
    --to=dmason@sarg.ryerson.ca \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).