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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@o...>
Subject: Re: [Caml-list] GC and file descriptors
On Wed, 2003-11-19 at 05:10, John J Lee wrote:
> On Tue, 19 Nov 2003, skaller wrote:
> > On Tue, 2003-11-18 at 23:05, Ville-Pertti Keinonen wrote:
> [...]
> > You haven't seen Python 2.2? Its a genuine functional
> > programming language now, with full lexical scoping,
> > closures, and even some advanced concepts like
> > iterators which cannot be programmed in Ocaml.
> [...]
> 
> Don't you mean generators?

Probably. You can write a function and yield a value
in the middle.. and then later continue on from
the yield point. The main use of such a beast
is to implement container iterators using
the closure state to maintain the position
in the container.

You can't do that (directly) in Ocaml.
Of course you can write:

	let make_f () =
		let state = ref 0 in	
		let f x = match !state with
		| 0 -> .... state := 6; retval1
		| 1 -> ...
	in f

but this is a real mess when you start nesting things...


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