Thanks all for your answers. The consensus seems to be that it is not possible to define an OCaml function returning recursive lists (or more generally recursive values), unless using various forms of tricks such as lazyness or Obj. So on the one hand we have OCaml functions as results of computations which are not analyzable, and on the other hand recursive (immutable) values which are analyzable but can only be defined instead of being computed.

 

I would not request any form of “improvement” in this area (as far as I’m concerned, I’m not comfortable with such recursive values); this was pure curiosity.

 

  Regards, Eric