Thread: "ocaml_beginners"::[] problem with recursive modules?
"ocaml_beginners"::[] problem
with recursive modules?
2006-12-08 12:43:20
Le ven 08 déc 2006 12:30:04 CET,
"drehman27" < drehman27%40yahoo.com">drehman27yahoo.com> a écrit :
> --- In ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com, Virgile Prevosto > <virgile.prevosto...> wrote:
> > module rec FooAlgorithm: Algorithm =
> > struct
> > ... BenchmarkFoo.f ...
> > end
> > and BenchmarkFoo = Framework(FooAlgorithm)
^^^
Note the 'and' here instead of 'module'
> module rec FooAlgorithm : Algorithm =
> struct
> 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.
"ocaml_beginners"::[] Re:
problem with recursive modules?
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:
>
> 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:
> > > module rec FooAlgorithm: Algorithm =
> > > struct
> > > ... BenchmarkFoo.f ...
> > > end
> > > and BenchmarkFoo = Framework(FooAlgorithm)
> ^^^
> Note the 'and' here instead of 'module' >
> > module rec FooAlgorithm : Algorithm =
> > struct
> > 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
>