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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Shawn Wagner <shawnw@s...>
Subject: Re: [Caml-list] help
On Sat, Apr 17, 2004 at 04:59:45AM +1000, skaller wrote:
> On Sat, 2004-04-17 at 04:04, mohammad siddiqui wrote:
> > Hi,
> > I started the conversion project after completely getting hold of ocaml but 
> > I still have some concerns like how we can manage pinters and pointer to 
> > pointers,
> 
> Generally you don't need them. Here is an example: in C:
> 
> struct ilist { list *next; int v; };
> 
> In Ocaml:
> 
> type ilist = Cons of int * ilist | Empty

This seems like a bad example, as you're just reinventing int list with it.

C pointers are something like ocaml references.

C: int *foo = &bar;
   *foo = 12;
   printf("%d", *foo);

Ocaml: let foo = ref bar in
        foo := 12;
	Printf.printf "%d" !foo
	
except that the value of bar won't be changed in the latter.	

> 
> >  some functions in C like exit(), isspace().
> 
> exception Exit
> The Exit exception is not raised by any library function. It is provided
> for use in your programs.

There's also the exit function, which does the same thing as C exit(), and
doesn't cause a message about an uncaught exception...

> 
> isspace is easy to implement:
> 
> let isspace = function
> | ' ' | '\t' -> true
> | _ -> false

\r, \n and some other characters also count as whitespace. The C character
classification routines (isspace, isalpha, etc.) are part of extlib.

-- 
Shawn Wagner
shawnw@speakeasy.org

-------------------
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