Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] (Sorry for my last post) lazyness, exceptions?, ocaml syntax rule-of-thumbs
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Kontra, Gergely <kgergely@m...>
Subject: Re: [Caml-list] (Sorry for my last post) lazyness, exceptions?, ocaml syntax rule-of-thumbs
>>   > One point was ocaml is really obscure is the file reading: it needed to
>>   > wrap the line-reading in an infinite loop, and this loop is ended via an
>>   > exception. I think End_of_file is not an exception, it is just an event.
>
>What next ? int_of_string "foo" returning None ?
No, that wouldn't be a good idea.
But writing int_of_string "foo" is a bad thing, while the end-of-file
thing is not a design problem. Is there a function to test eof? (without
consuming a line?)

>If you want to read a whole file as a string, you can use the
>following function:
[snip]
Well, but what about memory usage?
I just miss an iterator, or sg. like that, which reads a line, processes
it, reads next line...
Just want to write cleaner, which eg. in ruby is just (so intuitive)

IO.foreach("filename.ext") {|line|
	# process line
}

and don't like infinite loops.

Gergo

+-[Kontra, Gergely @ Budapest University of Technology and Economics]-+
|         Email: kgergely@mcl.hu,  kgergely@turul.eet.bme.hu          |
|  URL:   turul.eet.bme.hu/~kgergely    Mobile: (+36 20) 356 9656     |
+-------"Olyan langesz vagyok, hogy poroltoval kellene jarnom!"-------+
.
Magyar php mirror es magyar php dokumentacio: http://hu.php.net



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