Browse thread
[Caml-list] ocaml killer
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2004-01-30 (05:49) |
From: | Brian Hurt <bhurt@s...> |
Subject: | Re: [Caml-list] ocaml and concurrency |
On Fri, 30 Jan 2004, Martin Berger wrote: > > Perhaps because you're a type theorist? <g> > > being a type theorist has many disadvantages ... > > > C not only *does* have function types, it has > > first class function values just like ML does. > > well, i'm not so sure about this for two reasons. Technically, he's correct. What C doesn't have is partial function application, which makes having functional types much less worthwhile- it's impossible for a function type to also contain state. Which is why when I do callbacks in C, I always include a void * context which is passed (uninspected) to the callback routine. I mean, writting this function in C would be interesting to say the least: let summer ival = let cval = ref ival in let f x = cval := !cval + x; !cval in f ;; C's type syntax also discourages you from using pointers to functions. I've been programming C way too long, I can just dash out prototypes like: extern int (*)(int (*)(int), int) foo(int (*)(int (*)(int), int), int); I can parse them too, although normally I *would* use typedefs. The ocaml equivelent type: ((int -> int) -> int -> int) -> int -> ((int -> int) -> int -> int) is easier to read and easier to type and parse. > > firstly, NULL-pointers (i'm assuming that in C/C++ function > pointers can be NULL, though it's been too long for me to remember > precisely). They can. You can even cast integer values to be function pointers- and I have, legitimately (hint: BIOS functions). I've also debugged bugs where wild pointers where clobbering function pointers, and boy wasn't that fun. I'm not sure I'd compare NULL to variant types. It's more like a standardized abuse of C's concept of a pointer. -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford Brian ------------------- 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