Reputation: 99526
Core Language
dec ::= val ⟨var⟩(,) valbind value fun ⟨var⟩(,) funbind function type typbind type datatype datbind ⟨withtype typbind⟩ data type datatype id = datatype longid data type replication abstype datbind ⟨withtype typbind⟩ with dec end abstract type exception exnbind exception structure strbind structure (not allowed inside expressions) empty
Module Language
Programs
prog ::= dec core declaration functor fctbind functor declaration signature sigbind signature declaration empty prog1 ⟨;⟩ prog2 sequence fctbind ::= id1 ( id2 : sig ) ⟨:⟨>⟩ sig⟩ = str ⟨and fctbind⟩ plain id ( spec ) ⟨:⟨>⟩ sig⟩ = str ⟨and fctbind⟩ opened sigbind ::= id = sig ⟨and sigbind⟩ signature
Are structure, signature and functor all concepts in the module language, not in the core language?
I was wondering why does a structure declaration structure strbind
enter a program as a declaration dec
through the core language, instead of the module language?
In other words, why is a structure declaration structure strbind
classified as a declaration dec
in the core language, instead of the module language, unlike signature declarations signature sigbind
and functor declarations functor fctbind
?
Upvotes: 0
Views: 57
Reputation: 36118
Structure declarations are part of the module system. But they are allowed inside structure expressions, unlike functor and signature declarations. None of them is allowed inside the core level.
Technically, there are three levels of declarations in the actual language specification: core dec, structure dec, toplevel dec. The grammar you're looking at simplifies that a little, to avoid too much duplication.
Upvotes: 1