- 1、本文档共45页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
DirectiveStrangeLove,OrHowILearnedToStopWorrying.ppt
Directive Strange Loveor: How I Learned To Stop Worrying And Love the Macro Bill McCloskey with Rob von Behren Jeremy Condit Feng Zhou starring Eric Brewer as Gen. “Buck” Turgidson George Necula as Dr. Strangelove Introduction The C preprocessor has serious problems Goal: To replace it with something better that has comparable functionality This talk will focus on macros, but includes and conditional compilation are future work Quick Overview The C preprocessor (cpp) operates on streams of tokens, not on syntax trees Leads to strange possibilities: This example is contrived, but actual code is at least as inscrutable Consequently, analysis tools ignore cpp Quick Overview Any analysis that ignores cpp will give inadequate error messages Same as with C++ templates Even if error messages are improved, compiler will never understand the semantics of a macro Side effects? Context (expression, statement, type)? Argument types? Quick Overview Consequently, macros are error-prone According to Ernst et al., ~23% of macros contain possible errors Unparenthesized formals Multiple formal uses Free variables Unparenthesized bodies Dangling semicolons Quick Overview Although macros present difficulties, they are useful Perl source code contains ~0.6 macros per line, and it would be unreadable without them Quick Overview Why not create a new language that is less error-prone and easier to analyze? Operate on syntax trees instead of tokens Eliminate weird semantics C++ made an effort in this direction Constants Inline functions But need something more expressive Overview The preprocessor is bad! How is the preprocessor used? What language features could replace it? How can we make use of old programs? Preprocessor Patterns Ernst et al. examine common macro uses Constants and expressions are 75% of definitions Statements, types, declarations account for most of the rest Goal: To design a replacement macro language that can express almost everything that cpp can expr
您可能关注的文档
- DerechodeFamiliayNiezDepartamentodeDerecho.ppt
- Descentoftremorsourcelocationsbeforethe2014phreatic.PDF
- DescriptiveStatistics(Chapter3).doc
- DescriptiveStatisticsMeasuresofCentral-Fairfield.ppt
- Design,MachiningandInstallationManual.PDF
- Design-of-Shafts.doc.doc
- DesignConsiderationsinCasting.ppt
- DesigningAluminiumBronzeCastings-Copper.PDF
- DesigningPrimersforThreePieceRecombinantPCR-ITD.doc
- Designofheatexchangers.ppt
文档评论(0)