What's the "revised syntax" in OCaml?
Asked Answered
G

2

11

When people refer to the "revised syntax" in OCaml, do they mean that this will become a new syntax for the language, or is it just an alternative syntax created in CamlP4? If it's the former, then when does the "revised syntax" become the "official syntax" of OCaml?

Gastrology answered 26/5, 2010 at 23:32 Comment(0)
L
11

The revised syntax is just an alternative to the original that is implemented in Camlp4/5 (there is also a Lisp syntax written in Camlp5). Some people prefer it, but I would discourage you from using it as it's only likely to make your code more confusing for other OCaml programmers. One place it's valuable to know the revised syntax is when you're writing Camlp4/5 extensions---the revised syntax is used for patterns and rewrites, probably because it's somewhat more consistent than the original.

As far as I know, there is no plan to replace the original OCaml syntax with the revised syntax.

Loney answered 27/5, 2010 at 0:40 Comment(4)
"but I would discourage you from using it as its only likely to make your code more confusing for other OCaml programmers" - he he, then you better discourage using ocaml at all, as it will confuse far more people :)). Anyway, you can write quotations with original syntax, but there are some cases which cannot be expressed in original syntax, so revised is usually preferred for that task. As for usual programming - revised syntax is arguably more logical and easier for newbies (thats why it exists after all) - without many ambiguities of the original one.Autorotation
ygrek, I make no representation about which syntax is better. I do think a small- to medium-sized community like OCaml's should work hard not to fragment around dialects.Loney
Another point against revised syntax: poor(er) editor support. Neither Tuareg nor Vim's OCaml facilities support it to my knowledge.Maladapted
The one reason I haven't looked at OCaml seriously is because of that stupid old syntax. C'mon ;;?Thyroiditis
S
3

This is just an alternative concrete syntax. I think that's just to demonstrate how powerful camlP4 is, a kind of proof of concept.

Sternick answered 26/5, 2010 at 23:43 Comment(2)
It is not a proof of concept - it covers all the features of the language as the original one.Autorotation
that's just a proof of the concept that you can have several concrete syntaxs. That was what i meant... because i don't think many people are actually using the revised syntax.Sternick

© 2022 - 2024 — McMap. All rights reserved.