-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
「第三章」建议介绍一下 MIR 的使用方式 #41
Comments
@keroro520 感谢建议。 MIR在第五章 5.8 非词法作用域生命周期有详细介绍,因为NLL的检查机制是依赖于MIR。单独介绍MIR的话,可能会比较突兀。 另外,Constructor-as-functions,我并没有单独拿出来讲,而是融入到具体的示例中了。可以在看的时候发现。 期待你更多反馈。 |
@keroro520 补充 书里的「函数指针类型」,是指「函数指针的类型签名」。我的本意是指,它是一个函数指针,具有指示的一个类型签名。 |
@keroro520 正好,另外一个issues里,我回答了MIR相关的一些内容,你可以看看。 |
@keroro520 关于函数指针类型这个问题,也最好看看那个 函数指针类型的一点建议 #42 |
「“这样的枚举值本质上属于函数指针类型”」 修订为: 「函数项类型(Function-Item Type),它可以通过显式地指定函数类型来转换为函数指针类型(Function-Pointer Type)。但如无必要,不要进行这样的显式转换,默认使用函数项类型性能更好。」 |
我目前只看到第三章,不知道这个建议有没有在后面章节做了。
MIR 一定程度上表示了 “源代码在编译器眼中是什么样子的”。所以我为了查看 MIR,找了很久,最后才(只)知道可以通过 https://play.rust-lang.org 来查看。
我认为了解 MIR ,这种从编译器的视角去看代码的方式,能帮助我们更深刻地了解 Rust 的心智模型。所以建议书中介绍一下,怎么查看 MIR。
另外,在 P37 中介绍枚举体 “这样的枚举值本质上属于函数指针类型”。我第一次知道这个知识点时是有点震惊的,而如果能此时够贴上相应的 MIR,相信更能解释这个知识点。
如果在这个知识点下面,再继续普及一下 constructors-as-functions ,就更好了。
The text was updated successfully, but these errors were encountered: