Sml 结构声明是核心语言声明还是模块语言声明?
在 核心语言Sml 结构声明是核心语言声明还是模块语言声明?,sml,ml,Sml,Ml,在 核心语言 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 da
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
模块语言
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
节目
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
结构、签名和函子是否都是模块语言中的概念,而不是核心语言中的概念
我想知道为什么结构声明structure strbind
通过核心语言而不是模块语言作为声明dec
输入程序
换句话说,为什么结构声明structure strbind
在核心语言中被归类为声明dec
,而不是模块语言,而不像签名声明signature sigbind
和函子声明函子fctbind
谢谢。结构声明是模块系统的一部分。但与函子和签名声明不同,它们允许在结构表达式中使用。它们都不允许进入核心级别 从技术上讲,在实际的语言规范中有三个级别的声明:core-dec、structure-dec、top-level-dec。您所看到的语法稍微简化了这一点,以避免过多的重复