New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Wish: class types that constrain #3323
Comments
Comment author: administrator
IIRC, the reason is two-fold. So we could consider the following situation class c : object method y : float end = class d = object let _ = (new d)#y Since public methods are looked up by name, self#x becomes 1 rather The second reason is that the relation required between the interface
Private methods use private labels in place of names, and a different There is really nothing wrong in having only private methods, since class c : object method x : int end =
You can define only private methods in your base class, and inherit Jacques |
Comment author: administrator Hiding public methods is indeed unsound. |
Original bug ID: 1132
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: chris quinn
Version: 3.04
OS:
Submission from: 212.42.169.63 (212.42.169.63)
Why is it that a class type is not analogous to signatures by being applicable
to a class containing extra methods which require hiding?
class type t = object end
class ic = object
method x = 0
end
class t' arg1 arg2 : t = object
inherit ic
end
The compiler complains that method x cannot be hidden.
Note the presence of arguments to class t' - I want to define functions
in terms of a class type free of types of arguments used in construction.
Therefore I must specify an explicit class type, in this case t.
And the only way I can find to accommodate the compiler is
to declare in t' :
method private x = x
Yuk! Why should I need to do this? Is it not redundant?
In my situation I have a lot of classes inheriting class ic and whenever I add a
method to it I must revisit them all and add the above line!
So it would be nice if class types could constrain but I half suspect there is
good reason this is not the case!
Thanks.
The text was updated successfully, but these errors were encountered: