Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] static variables in a function
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Shannon --jj Behrens <jjinux@y...>
Subject: Re: [Caml-list] static variables in a function
Thank you all for your speedy, helpful responses!  I
am also happy to see rough concensus in the correct
way to do this.

Thanks Again,
-jj

--- Yutaka OIWA <oiwa@yl.is.s.u-tokyo.ac.jp> wrote:
> >> On Fri, 14 Jun 2002 10:08:30 -0700 (PDT), Shannon
> --jj Behrens <jjinux@yahoo.com> said:
> 
> Shannon> Hi,
> Shannon> What is the correct OCAML idiom for
> achieving the
> Shannon> following psuedocode?
> 
> Shannon> let get_chunk () =
> Shannon>   static chunks_list;
> 
> Shannon>   if List.is_empty chunks_list
> Shannon>   then chunks_list = get_more_chunks ();
> Shannon>   shift chunks_list
> Shannon> ;;
> 
> How about this?
> 
> let get_chunk =
>   let chunks_list = ref [] in
>   fun () ->
>     ...
> 
> -- 
> Yutaka Oiwa              Yonezawa Lab., Dept. of
> Computer Science,
>       Graduate School of Information Sci. & Tech.,
> Univ. of Tokyo.
>       <oiwa@yl.is.s.u-tokyo.ac.jp>,
> <yutaka@oiwa.shibuya.tokyo.jp>
> PGP fingerprint = C9 8D 5C B8 86 ED D8 07  EA 59 34
> D8 F4 65 53 61


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
-------------------
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