List Info

Thread: "ocaml_beginners"::[] problem with recursive modules?




"ocaml_beginners"::[] problem with recursive modules?
user name
2006-12-08 12:43:20

Le ven 08 déc 2006 12:30:04 CET,
&quot;drehman27" < drehman27%40yahoo.com">drehman27yahoo.com> a écrit :
> --- In ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com, Virgile Prevosto
> <virgile.prevosto...> wrote:
&gt; > module rec FooAlgorithm: Algorithm =
> > struct
&gt; > ... BenchmarkFoo.f ...
> > end
> > and BenchmarkFoo = Framework(FooAlgorithm)
^^^
Note the 'and' here instead of 'module'

> module rec FooAlgorithm : Algorithm =
> struct
&gt; let run_algorithm () = ()
> let results () = BenchmarkFoo.print_benchmark_results ()
> end
>
> module BenchmarkFoo = Framework(FooAlgorithm)

You have to tell ocaml that FooAlgorithm and BenchmarkFoo are in the
same recursive block, using the 'and' keyword (exactly like in
let rec f x = ... and g y = ... for functions). Otherwise, only
FooAlgorithm is considered recursive, while BenchmarkFoo is an
ordinary module.

--
E tutto per oggi, a la prossima volta.
Virgile

__._,_.___
.

__,_._,___
"ocaml_beginners"::[] Re: problem with recursive modules?
user name
2006-12-08 14:04:17

I tried with 'and' keyword but I get a syntax error!
I am using ocaml 3.0.9.2

--- In ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com, Virgile Prevosto
<virgile.prevosto...> wrote:
&gt;
> Le ven 08 déc 2006 12:30:04 CET,
> "drehman27" <drehman27...> a écrit :
> > --- In ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com, Virgile Prevosto
> > <virgile.prevosto> wrote:
&gt; > > module rec FooAlgorithm: Algorithm =
> > > struct
&gt; > > ... BenchmarkFoo.f ...
> > > end
> > > and BenchmarkFoo = Framework(FooAlgorithm)
> ^^^
> Note the 'and' here instead of 'module'
>
> > module rec FooAlgorithm : Algorithm =
> > struct
&gt; > let run_algorithm () = ()
> > let results () = BenchmarkFoo.print_benchmark_results ()
> > end
> >
> > module BenchmarkFoo = Framework(FooAlgorithm)
>
> You have to tell ocaml that FooAlgorithm and BenchmarkFoo are in the
> same recursive block, using the 'and' keyword (exactly like in
> let rec f x = ... and g y = ... for functions). Otherwise, only
> FooAlgorithm is considered recursive, while BenchmarkFoo is an
> ordinary module.
&gt;
> --
> E tutto per oggi, a la prossima volta.
&gt; Virgile
&gt;

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )