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
"tuareg-eval-phrase" Error with class type #239
Comments
Lex "type" after "class" as "c-type", in analogy with "m-type".
This patch seems to work. Drawback: the indentation of your example is not preserved; that is,
is indented as
which corresponds to the indentation of class definitions:
On the other hand, putting
which was not the case before. In other words: the patch fixes the |
Lex "type" after "class" as "c-type", in analogy with "m-type".
No more 'Syntax error' : well done. Note: I don't have your indentation problem. So, for me, this issue can be closed. |
Thanks for confirming, and yes, ocp-indent uses different rules. It appears that tuareg's class indentation,
is very much intended (see bcad60e) but it's unclear to what extension it describes a consensus among OCaml programmers. The OCaml source tree itself is inconsistent in this respect, but that is not unexpected for a long-lived code base with many contributors. It looks like the indentation consequences of the patch are neutral at worst, and fixing the parsing bug is worth it. |
Thanks for confirming, and yes, ocp-indent uses different rules. It appears
that tuareg's class indentation,
```
class c =
object
method m = ()
end
```
is very much intended (see bcad60e) but
It should be easy to add a config var to control that, if we want to.
We could also make it so that we get:
```
class c =
object
method m = ()
end
```
but still keep
```
class c = object
method m = ()
end
```
which has the advantage of allowing the programmer to choose between the
two indentations without having to tweak a config var (so it works the
same for all those using Tuareg).
it's unclear to what extent it describes a consensus among OCaml
programmers. The OCaml source tree itself is inconsistent in this respect,
but that is not unexpected for a long-lived code base with
many contributors.
The lack of a good auto-indenter for much of the life of (O)Caml made
for a rather anarchic style, I guess (I haven't looked enough at
other people's OCaml code to be sure, but that's what I'd expect from
my experience with SML).
It looks like the indentation consequences of the patch are neutral at
worst, and fixing the parsing bug is worth it.
And it shouldn't be terribly hard to change the indentation separately
if needed.
|
Yes, that would coincide with ocp-indent – I think that would be preferable, and
This patch OK then? |
Lex "type" after "class" as "c-type", in analogy with "m-type".
Indent non-hanging `object` instead of aligning with their preceding `class` token. Previously: class c = object method m = 1 end Now: class c = object method m = 1 end which agrees with default ocp-indent and seems to be the more modern usage. Also indent `initialize` clauses correctly. (ocaml#239)
This should now be fixed; close if you agree. |
Done. |
OCaml 4.11.1 - Tuareg 2.2.0 - The Merlin toolkit v3.3.9, for OCaml 4.11.1 - Emacs 28.0.50
Example from https://caml.inria.fr/pub/docs/manual-ocaml-4.11/objectexamples.html#s:class-interfaces
The text was updated successfully, but these errors were encountered: