Skip to content
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

Closed
keroro520 opened this issue Jan 9, 2019 · 5 comments
Closed

「第三章」建议介绍一下 MIR 的使用方式 #41

keroro520 opened this issue Jan 9, 2019 · 5 comments
Labels
已修订 已经修订并提交给出版社 已回答 已回答请教的问题 第三章 第三章 读者建议 来自读者对本书的建议

Comments

@keroro520
Copy link

我目前只看到第三章,不知道这个建议有没有在后面章节做了。

MIR 一定程度上表示了 “源代码在编译器眼中是什么样子的”。所以我为了查看 MIR,找了很久,最后才(只)知道可以通过 https://play.rust-lang.org 来查看。

我认为了解 MIR ,这种从编译器的视角去看代码的方式,能帮助我们更深刻地了解 Rust 的心智模型。所以建议书中介绍一下,怎么查看 MIR。

另外,在 P37 中介绍枚举体 “这样的枚举值本质上属于函数指针类型”。我第一次知道这个知识点时是有点震惊的,而如果能此时够贴上相应的 MIR,相信更能解释这个知识点。
如果在这个知识点下面,再继续普及一下 constructors-as-functions ,就更好了。

@ZhangHanDong
Copy link
Owner

ZhangHanDong commented Jan 9, 2019

@keroro520 感谢建议。

MIR在第五章 5.8 非词法作用域生命周期有详细介绍,因为NLL的检查机制是依赖于MIR。单独介绍MIR的话,可能会比较突兀。

另外,Constructor-as-functions,我并没有单独拿出来讲,而是融入到具体的示例中了。可以在看的时候发现。

期待你更多反馈。

@ZhangHanDong ZhangHanDong added the 读者建议 来自读者对本书的建议 label Jan 9, 2019
@ZhangHanDong ZhangHanDong added the 已回答 已回答请教的问题 label Jan 9, 2019
@ZhangHanDong ZhangHanDong added this to the 第三次印刷 milestone Jan 9, 2019
@ZhangHanDong
Copy link
Owner

ZhangHanDong commented Jan 9, 2019

@keroro520 补充

书里的「函数指针类型」,是指「函数指针的类型签名」。我的本意是指,它是一个函数指针,具有指示的一个类型签名。
考虑在第三次印刷中再完善下叙述。

@ZhangHanDong ZhangHanDong reopened this Jan 9, 2019
@ZhangHanDong
Copy link
Owner

@keroro520 正好,另外一个issues里,我回答了MIR相关的一些内容,你可以看看。

函数指针类型的一点建议 #42

@ZhangHanDong
Copy link
Owner

@keroro520 关于函数指针类型这个问题,也最好看看那个 函数指针类型的一点建议 #42

@ZhangHanDong ZhangHanDong changed the title 建议介绍一下 MIR 的使用方式 「第三章」建议介绍一下 MIR 的使用方式 Jan 10, 2019
@ZhangHanDong ZhangHanDong added the 第三章 第三章 label Jan 14, 2019
@ZhangHanDong ZhangHanDong added the 已修订 已经修订并提交给出版社 label Jan 21, 2019
@ZhangHanDong
Copy link
Owner

@keroro520

「“这样的枚举值本质上属于函数指针类型”」

修订为:

「函数项类型(Function-Item Type),它可以通过显式地指定函数类型来转换为函数指针类型(Function-Pointer Type)。但如无必要,不要进行这样的显式转换,默认使用函数项类型性能更好。」

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
已修订 已经修订并提交给出版社 已回答 已回答请教的问题 第三章 第三章 读者建议 来自读者对本书的建议
Projects
None yet
Development

No branches or pull requests

2 participants