Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a draft PR for adding a syntax for object-based custom tags in MLX.
I will note that I was unable to figure out how to get
ocamlmerlin_mlx
to work with this as I don't have a good understanding of how MLX is extending merlin and where the changes would need to be made -- if I could be pointed in the right direction I will be happy to make those changes myself. The syntax itself is working. Some of my changes to the parser could probably be streamlined too by someone more knowledgeable in Menhir.The syntax
<obj#view> children </obj#view>
<obj#view />
<obj# />
where
obj
is an Ocaml object with the methodview
. The method can have any name or, if not specified and only the hash is added, the methodmake
will be inferred.Why do this?
Objects are a part of the Ocaml ecosystem. While they are sometimes maligned, they have many legitimate use cases -- open recursion being the key example. In the wider programming world, objects are widely considered good fit for GUI building. I personally have found the lack of object components to be a major pain point in my project. While some of their use cases can be subsumed by first class modules -- these tend to be syntactically heavy and don't provide a good alternative when the problem at hand is best solved by open recursion or inheritance.
Object-based components let users of MLX take advantage of objects without having to use heavy syntax or packing object methods into an identifier. There seem to be no clear disadvantages to adding this feature -- most OCamler's are pretty averse to objects too so I don't think they're likely to go crazy with them and get themselves in trouble.