English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    
Browse thread
Re: [Caml-list] Naming conventions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dave Mason <dmason@s...>
Subject: Re: [Caml-list] Naming conventions
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