Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006130OCamlOCaml typingpublic2013-08-13 22:082013-12-12 23:03
Reportergerd 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version4.00.1 
Target VersionFixed in Version 
Summary0006130: Wish: when inheriting from class types, allow to subtype methods
DescriptionCurrently, this does not work:

class type x = object
  method p : [ `P ] -> unit
  (* many more methods *)
end

class type y = object
  inherit x
  method p : [ `P | `Q ] -> unit
end

The suggestion is to allow that method types can be subtypes of the inherited types (maybe requiring method! syntax).
Additional InformationThis 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.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0010206)
garrigue (manager)
2013-08-20 10:49

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

- Issue History
Date Modified Username Field Change
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
Powered by Mantis Bugtracker