O Plameras wrote:
> Hi,
> Is their equivalent codes for ff in perl 6 ?
> I've been told there is none in O'Caml as pointer is not available.
The C equivalent of function pointers do exist in O'caml.
The C example is rather silly, but here's the O'caml equivalent:
let print_sign x =
if x >= 0 then
Printf.printf "% d is positive\n" x
else
Printf.printf "% d is negative\n" x
;;
let arr = [| -1 ; 0 ; 1 ; 0 ; 2 ; 9 ; 3200 ; -3500 |] ;;
Array.map print_sign arr ;;
For just about everything you can do with a pointer in C there is
a better, easier, less error prone way to do the same thing in
O'caml and write less lines of code to do it. The one exception
I can thing of is writing devices drivers and operating systems
where you need to direct access to harware.
Erik
--
+-----------------------------------------------------------+
Erik de Castro Lopo
+-----------------------------------------------------------+
"... a discussion of C++'s strengths and flaws always sounds
like an argument about whether one should face north or east
when one is sacrificing one's goat to the rain god."
-- Thant Tessman
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html