MetaOCaml unqualified constructor

100 views Asked by At
type t = A;;
.<A>.;;

will give error Unqualified constructor A cannot be used within brackets. Put into a separate file.

What is the underlying reason of this error?

Some reference can be found here

1

There are 1 answers

0
ygrek On BEST ANSWER

Here is the official explanation - http://okmij.org/ftp/ML/MetaOCaml.html#ctors

My very vague guess would be that this restriction comes from the need to ensure that actually same variant definition is used at compile-time and run-time when referenced in staged code (because same code can and will be compiled at different points of time in run-time), by putting type declarations in separate modules they get hashed and checked by compiler with usual checks for interface matching. Also I think the possibility of shadowing plays some role here.