Struct, sig, do ... -> begin?

We have various syntactic structures that contain blocks of code, eg:

for ... do
end

module M = struct
end

module type MT = sig
end

We also have begin...end which seems to be a synonym for (...).

Is there some reason why we can’t use begin for all of the above blocks, or is it purely for historical reasons?

  1. You’d need to change the parser; it’s not backwards compatible.
  2. struct and sig can stand by themselves, without assignment. How would you indicate that you mean one or the other if you just use begin?

agreed, it’s no use if we just keep the two syntax side by side anyway.

you know from context when you’re in a module or module type context, so that’s not a problem, I think. module A = <module context here>, module type FOO = <module type context here>, open <module context here>, etc.

Just historical/tradition reasons. Technically there is no problem: ReasonML used { and } to delineate all blocks.

Cheers,
Nicolas