Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Newbie: declarations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Remi VANICAT <vanicat@l...>
Subject: Re: [Caml-list] Newbie: declarations
leary@nwlink.com writes:

> On Sun, Jun 17, 2001 at 02:08:28PM +0400, Vitaly Lugovsky wrote:
> >  It's an almost functional language, so please avoid variables. And use
> > references only when you really need 'em. Refer to the Guide about
> > references and named tuples.
> 
> Here's what I'm doing now (comments welcome; yes, I have short cryptic
> names).  I'm writing a robot for RealTimeBattle, and want to have access to
> information that isn't contained in every message the robot gets (and I'm
> not using threads or signals yet, fwiw).  This information is updated all
> the time.  (I'll post a link to the whole thing for criticism, once it
> actually does something interesting. :)

[...]


> let data : datarec = {

the type annotation is not mandatory :
let data =
is enough

[...]


> 
> let initialize i = match i with
> 	1 -> name "Bob"; color "00FF00 FF0000";
> 		debug "initialize 1\n";
> 	| 0 -> 
> 		data.name <- "bob";

[...]

it may be better to have two function : one to initialize the robot,
the other to make the other stuff.

-- 
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
-------------------
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