From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id GAA25372; Fri, 30 Jan 2004 06:49:49 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id GAA25552 for ; Fri, 30 Jan 2004 06:49:47 +0100 (MET) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id i0U5nkP18852 for ; Fri, 30 Jan 2004 06:49:46 +0100 (MET) Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.11.6/8.10.1) with ESMTP id i0U5nPZ26657; Thu, 29 Jan 2004 23:49:34 -0600 (CST) Date: Fri, 30 Jan 2004 00:52:42 -0600 (CST) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: Martin Berger cc: skaller@tpg.com.au, The Trade Subject: Re: [Caml-list] ocaml and concurrency In-Reply-To: <40199FE0.1070100@dcs.qmul.ac.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 theorist:01 theorist:01 callbacks:01 callback:01 c's:01 discourages:01 pointers:01 extern:01 foo:01 typedefs:01 pointers:01 bios:99 c's:01 standardized:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 30 Jan 2004, Martin Berger wrote: > > Perhaps because you're a type theorist? > > 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