* ocamlbuild rule with recursive action
@ 2008-12-02 10:40 Daniel Bünzli
2008-12-02 11:27 ` [Caml-list] " DooMeeR
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Bünzli @ 2008-12-02 10:40 UTC (permalink / raw)
To: OCaml List
Hello,
Is it possible to define a rule with an action that is performed
repeatedly until a condition is reached ?
Best,
Daniel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild rule with recursive action
2008-12-02 10:40 ocamlbuild rule with recursive action Daniel Bünzli
@ 2008-12-02 11:27 ` DooMeeR
2008-12-02 23:51 ` Daniel Bünzli
0 siblings, 1 reply; 5+ messages in thread
From: DooMeeR @ 2008-12-02 11:27 UTC (permalink / raw)
To: Daniel Bünzli; +Cc: OCaml List
Daniel Bünzli a écrit :
> Hello,
>
> Is it possible to define a rule with an action that is performed
> repeatedly until a condition is reached ?
>
> Best,
>
> Daniel
Well, you can define a rule like this :
rule ~prod: "%.rec" (fun env build ->
let x = env "%2.rec" in (* a new fresh name *)
if some condition then build x else Nop)
When your rule is executed, for exemple to produce "toto.rec", it will
(if some condition) first produce "toto2.rec", which will produce
"toto22.rec", and so on until some condition is false.
I didn't try it though.
--
Romain Bardou
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild rule with recursive action
2008-12-02 11:27 ` [Caml-list] " DooMeeR
@ 2008-12-02 23:51 ` Daniel Bünzli
2008-12-03 9:44 ` Romain Bardou
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Bünzli @ 2008-12-02 23:51 UTC (permalink / raw)
To: OCaml List
Le 2 déc. 08 à 12:27, DooMeeR a écrit :
> Well, you can define a rule like this :
Thanks. I'll try something along these lines.
But that's kind of ugly. In the future could maybe ocamlbuild add
another case in the command type, something like
Rec of action -> (command * bool)
Or maybe there is another way ?
Daniel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild rule with recursive action
2008-12-02 23:51 ` Daniel Bünzli
@ 2008-12-03 9:44 ` Romain Bardou
2008-12-03 9:58 ` Daniel Bünzli
0 siblings, 1 reply; 5+ messages in thread
From: Romain Bardou @ 2008-12-03 9:44 UTC (permalink / raw)
To: Daniel Bünzli; +Cc: OCaml List
Daniel Bünzli a écrit :
>
> Le 2 déc. 08 à 12:27, DooMeeR a écrit :
>
>> Well, you can define a rule like this :
>
> Thanks. I'll try something along these lines.
>
> But that's kind of ugly. In the future could maybe ocamlbuild add
> another case in the command type, something like
>
> Rec of action -> (command * bool)
>
> Or maybe there is another way ?
>
> Daniel
Well, you can also simply execute the commands yourself, in a loop,
using Command.execute or Command.execute_many.
--
Romain Bardou
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild rule with recursive action
2008-12-03 9:44 ` Romain Bardou
@ 2008-12-03 9:58 ` Daniel Bünzli
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Bünzli @ 2008-12-03 9:58 UTC (permalink / raw)
To: OCaml List
Le 3 déc. 08 à 10:44, Romain Bardou a écrit :
> Well, you can also simply execute the commands yourself, in a loop,
> using Command.execute or Command.execute_many.
But doesn't this break things ? Actions are supposed to build the
command not execute it.
Daniel
P.S. something like
Rec of 'a * ('a -> action -> [ `Stop | `Step of command * 'a ])
would be better or
Rec of 'a * ('a -> action-> command * 'a) with the convention that
returning Nop stops the recursion.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-12-03 9:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-02 10:40 ocamlbuild rule with recursive action Daniel Bünzli
2008-12-02 11:27 ` [Caml-list] " DooMeeR
2008-12-02 23:51 ` Daniel Bünzli
2008-12-03 9:44 ` Romain Bardou
2008-12-03 9:58 ` Daniel Bünzli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox