简体   繁体   English

为什么'let x = 1'有效的F#表达式?

[英]Why is 'let x = 1' valid F# expression?

I am trying to write F# parser. 我正在尝试编写F#解析器。 According to the specification the let expression looks like: 根据规范 ,let表达式如下:

let value-defn in expr

I am using Try F# for testing. 我正在使用Try F#进行测试。 I tried following code which is parsed without error. 我尝试下面的代码,解析没有错误。

#light "off"
let a = 1

Yet according to the manual, should always contain in keyword. 然而,根据手册中,应始终包含的关键字。 Why is it valid F# code? 为什么它是有效的F#代码?

This is actually covered by another part of the spec (A.2.1.1) 这实际上是由规范的另一部分所涵盖的(A.2.1.1)

module-function-or-value-defn : module-function-or-value-defn:

  attributesopt let function-defn attributesopt let value-defn 

Since you are defining something in a module directly, it doesn't need the in 既然你是在一个模块中直接定义的东西,它不需要in

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM