|Anonymous | Login | Signup for a new account||2014-12-21 00:03 CET|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0006130||OCaml||OCaml typing||public||2013-08-13 22:08||2013-12-12 23:03|
|Target Version||Fixed in Version|
|Summary||0006130: Wish: when inheriting from class types, allow to subtype methods|
|Description||Currently, this does not work:|
class type x = object
method p : [ `P ] -> unit
(* many more methods *)
class type y = object
method p : [ `P | `Q ] -> unit
The suggestion is to allow that method types can be subtypes of the inherited types (maybe requiring method! syntax).
|Additional Information||This would be extremely helpful, because in some situations there is no easy workaround, especially if the definition of x is not in my own code base.|
As classes allow method overriding with subtypes, permitting the same for class types would also be good for the symmetry in the language.
|Tags||No tags attached.|
This is a long standing request.
There are 3 reasons it was not implemented:
1) since ocaml allows to use the "type of self", ensuring the soundness of this feature can be tricky.
(This looks ok, but I think nobody has proved that formally yet)
2) this requires important changes in the type inference of classes: currently, the typing of inheritance just uses unification, which is not compatible with subtyping
3) to preserve backward compatibility, all such methods would have to be explicitly annotated, so it would be a bit heavy to use
|2013-08-13 22:08||gerd||New Issue|
|2013-08-19 19:13||doligez||Severity||minor => feature|
|2013-08-19 19:13||doligez||Status||new => acknowledged|
|2013-08-20 10:49||garrigue||Note Added: 0010206|
|Copyright © 2000 - 2011 MantisBT Group|