English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] ocaml killer
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-01-30 (08:54)
From: Issac Trotts <ijtrotts@u...>
Subject: Re: [Caml-list] ocaml and concurrency
On Fri, Jan 30, 2004 at 12:52:42AM -0600, Brian Hurt wrote:
> 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
> ;;

OK, maybe C doesn't support it, but it's easy to do this one in C++:

#include <assert.h>

class summer
  int cval;
  summer(int ival): cval(ival) {} 
  int operator()(int x) { cval += x; return cval; }

int main()
  summer s(3);
  return 0;



Issac Trotts

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