You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 4471 Reporter: furr Status: acknowledged (set by @damiendoligez on 2008-01-10T10:46:12Z) Resolution: open Priority: normal Severity: feature Version: 3.10.0 Category: language features Monitored by:@gasche@jberdine "Julien Signoles" @hcarty@yakobowski
Bug description
The constraint on recursive module signatures to only contain function typed values is quite restrictive. Presumably, this is because initialization of these values would be difficult in the general case.
Examining my own uses of recursive modules, a significant improvement would be if constants were considered "safe", which could be accomplished with a kind of "value restriction" for modules. This solution would be nice because it is both already familiar to the seasoned OCaml programmer (from polymorphism) and would subsume the check for function values.
The text was updated successfully, but these errors were encountered:
11 years later, I'm not sure what has changed in OCaml's recursive modules, but signatures of recursively-defined modules can contain values that are not functions, and definitions by constants are supported (or expressions that don't get into a recursive cycle, more generally). Here are some examples in OCaml 4.07:
# module rec A : sig val x:int end = struct let x = 42 end;;
module rec A : sig val x : int end
# module rec A : sig val x:int end = struct let x = 42 end
and B : sig val y:int end = struct let y = A.x end;;
module rec A : sig val x : int end
and B : sig val y : int end
# module rec A : sig val x:int end = struct let x = B.y end
and B : sig val y:int end = struct let y = 42 end;;
module rec A : sig val x : int end
and B : sig val y : int end
# module rec A : sig val x:int end = struct let x = B.y + 1 end
and B : sig val y:int end = struct let y = A.x * 2 end;;
Error: Cannot safely evaluate the definition of the following cycle
of recursively-defined modules: A -> B -> A.
There are no safe modules in this cycle (see manual section 8.4)
Original bug ID: 4471
Reporter: furr
Status: acknowledged (set by @damiendoligez on 2008-01-10T10:46:12Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.10.0
Category: language features
Monitored by: @gasche @jberdine "Julien Signoles" @hcarty @yakobowski
Bug description
The constraint on recursive module signatures to only contain function typed values is quite restrictive. Presumably, this is because initialization of these values would be difficult in the general case.
Examining my own uses of recursive modules, a significant improvement would be if constants were considered "safe", which could be accomplished with a kind of "value restriction" for modules. This solution would be nice because it is both already familiar to the seasoned OCaml programmer (from polymorphism) and would subsume the check for function values.
The text was updated successfully, but these errors were encountered: