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 request: allow to declare a method final. #7041
Comments
Comment author: @garrigue I've thought of it a few times. On another note, this kind of additions have a very low probability of being accepted because objects in ocaml are not used much the way they are in OO languages. If you thought this by comparison with another language, you should maybe first check that there is not a more natural way to write your code in ocaml (maybe you don't need objects at all). |
Comment author: @alainfrisch
More like a compiler-checked assertion, which is much stronger than a comment and also useful to reason on the code.
I don't think this was indeed the intention of the suggestion, but aren't there cases where one could benefit of "final", as in: class c = object(this) ? Since one knows statically to what "this # bar" corresponds, this method call could be turned into a simple function call, no? |
Comment author: @garrigue
Right, the question is more how useful this would be in ocaml.
Method calls through self or an ancestor are already more efficient than from outside, as this just amounts to looking up the table at a fixed offset. Here is the code for it in the bytecode interpreter:
This is much better than a dichotomic search. |
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
Original bug ID: 7041
Reporter: @sbriais
Status: acknowledged (set by @xavierleroy on 2015-11-15T17:19:30Z)
Resolution: open
Priority: normal
Severity: feature
Category: language features
Monitored by: @gasche
Bug description
I think it would be useful to have a final qualifier to mark methods that cannot be overriden.
The text was updated successfully, but these errors were encountered: