英文:
Why is the Token type for Bool Missing in Go?
问题
我已经在审查《Go Token 文档》(https://cs.opensource.google/go/go/+/refs/tags/go1.17:src/go/token/token.go),并注意到 Go Token 类型中缺少 bool 类型。
是否有特定原因导致它未被包含在内?
英文:
I have been reviewing the Go Token Documentation and I have noted that the Go Token type for bool is missing.
Is there a reason why it's not included?
答案1
得分: 5
true
和false
是预声明标识符,而不是保留字。
在AST级别上,预声明标识符与其他标识符一样处理。预声明标识符由IDENT标记类型表示,并由scanIdentifier方法进行扫描。
假设没有遮蔽,这些标识符在名称解析期间绑定到全局块中的true
和false
。
英文:
true
and false
are predeclared identifiers, not reserved words.
At the level of the AST, predeclared identifiers are handled like all other identifiers. Predeclared identifiers are represented by the IDENT token type and are scanned by the scanIdentifier method.
Assuming no shadowing, the identifiers are bound to true
and false
in the universal block during name resolution.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论