为什么要在“导入”之间出现多行论。和ImportSpec,但不在Packagename和ImportPath之间?
这是导入声明的GO规格:
ImportDecl = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) .
ImportSpec = [ "." | PackageName ] ImportPath .
ImportPath = string_lit .
以下代码编译:
import /*
*/f "fmt"
但不是此代码:
import /*
*/f/*
*/"fmt"
更奇怪的是,此代码编译:
import /*
*/f /* */ "fmt"
我无法理解令牌中这些评论块之间的区别。
This is the Go spec for an import declaration:
ImportDecl = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) .
ImportSpec = [ "." | PackageName ] ImportPath .
ImportPath = string_lit .
The following code compiles:
import /*
*/f "fmt"
But not this code:
import /*
*/f/*
*/"fmt"
Even more strangely, this code compiles:
import /*
*/f /* */ "fmt"
I could not understand the difference between these comment blocks among the tokens.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
https://go.dev/play/p/nxvIDWkWf_q