Erlang for C, C++ and Java Programmers [zz]

本文探讨了Erlang语言的独特之处,包括原子的使用、模式匹配、函数替换以及链表操作的特点。此外还讨论了Erlang如何通过模式匹配和不可变变量避免副作用,以及这些特性如何与DDD理念相呼应。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://npt.cc.rsu.ru/user/wanderer/ODP/Erlang_tutorial.html

Atoms are used in places where in C one might define a constant

the = operator doesn't in fact mean assign, it means "match with".

-- match with -- unify 合一,prolog 里面的合一

the -> construct should be read as "evaluates to".

-- prolog 用 -> 表示替换

test(A) -> 1.

test(int a) {
return 1
};


This would be the idiomatic way to write this in Erlang, and in fact (in R8B) is evaluated more quickly than the case statement.

-- switch 语句可以使用函数来替换。c++ 的重载函数,多态体现在数据类型方便,Erlang 体现在数据值方面。

-- prolog 在求解过程中,使用 -> 替换进行穷举尝试。替换的依据是 rule 。

-- 在 list 中加入一个 item 。按 c++ 常规链表的实现方式,如果加入的 item 放到链表的最前面,那么只需要这个新的 item 指向原来的头部,而这个新的 item 成为新链表的标识。这样也就没违反 Erlang 的变量只能赋值一次的限制。

-- 但如果要插入一个 item 到链表中,那么就会引起连锁反应。假设链表已经有 2 个 item ,新 item 要插入到中间。那么除了最后一个 item 不需要改变之外,最前面的 item 需要改变它的 next 指针的指向,所以这个插入操作导致 copy 最前面的 item 。如果链表不止有两个 item ,那么一旦进行这样的插入,在插入点之前的所有 item 都会导致要 copy 一次。

-- Erlang 中变量只能赋值一次,同 DDD 中讲的 Query 和 Command 分离的想法很相似,都是避免副作用(side effect)。

Wings3D hold a list of funs which it uses as a stack.
Book Description Written for the moderately experienced Java programmer, this book builds on readers¿ existing knowledge of object-oriented programming and covers all important aspects of Standard C++—emphasizing more lower-level C-style details later in the presentation. Chapter topics include philosophy of C++, simplest C++, pointers and reference variables, object-based programming: classes, operator overloading, object-oriented programming: inheritance, templates, abnormal control flow, input and output, collections: the standard template library, primitive arrays and strings, C-style C++, and using Java and C++: the JNI. For new C++ programmers converted from Java. For experienced Java programmers and students who require the skills of C++ programming, best-selling author Mark Allen Weiss bridges the gap. He efficiently presents the complex C++ language in this well-designed tutorial/reference that both students and seasoned programmers will appreciate. The book is ideal as a primary text for intermediate C++ courses, as a supplemental no-nonsense reference for other courses, or for independent learning by professionals. C++ for Java Programmers is a concise, well-written text that provides authoritative and up-to-date coverage of key features and details of C++, with a special focus on how C++ compares to Java. The book's approach shows knowledgeable students or professionals how to grasp the complexities of C++ and harness its power by mutually addressing the benefits and the pitfalls of the two languages. By highlighting the features and comparative elements of each language, and building on the reader's existing knowledge of object-oriented programming, C++ for Java Programmers enables users to master the essentials of C++ quickly and thoroughly. Key Features Includes insightful comparisons of the two programming languages throughout the text and points out the subtleties of C++ Succinctly covers the pertinent highlights of STL (Standard Template Library) and the most effective use of templates Explains the use of the powerful JNI (Java Native Interface) for combining Java and C++ Includes a summary of key C++ features and issues with each chapter Provides extensive treatment of C details the programmer is likely to encounter in C++ Companion Website for complete online source code at: http://www.prenhall.com/weiss Available Instructors Resource CD-ROM Product Details Paperback: 304 pages Publisher: Prentice Hall; 1 edition (November 7, 2003) Language: English ISBN-10: 013919424X ISBN-13: 978-0139194245 Product Dimensions: 9.5 x 6.8 x 0.6 inches
C++ for Programmers: Deitel Developer Series by Paul Deitel, Harvey Deitel release type: eBook (.chm) release size: 4.80 MB Publisher: Prentice Hall PTR Pub Date: February 2, 2009 Print ISBN-10: 0137001304 Print ISBN-13: 978-0137001309 PRACTICAL, EXAMPLE-RICH COVERAGE OF: Classes, Objects, Encapsulation, Inheritance, Polymorphism Integrated OOP Case Studies: Time, GradeBook, Employee Industrial-Strength, 95-Page OOD/UML® 2 ATM Case Study Standard Template Library (STL): Containers, Iterators and Algorithms I/O, Types, Control Statements, Functions Arrays, Vectors, Pointers, References String Class, C-Style Strings Operator Overloading, Templates Exception Handling, Files Bit and Character Manipulation Boost Libraries and the Future of C++ GNU™ and Visual C++® Debuggers And more… VISIT WWW.DEITEL.COM For information on Deitel® Dive-Into® Series corporate training courses offered at customer sites worldwide (or write to deitel@deitel.com) Download code examples Check out the growing list of programming, Web 2.0 and software-related Resource Centers To receive updates for this book, subscribe to the free DEITEL® BUZZ ONLINE e-mail newsletter at www.deitel.com/newsletter/subscribe.html Read archived issues of the DEITEL® BUZZ ONLINE The professional programmer’s DEITEL® guide to C++ and object-oriented application development Written for programmers with a background in high-level language programming, this book applies the Deitel signature live-code approach to teaching programming and explores the C++ language and C++ Standard Libraries in depth. The book presents the concepts in the context of fully tested programs, complete with syntax shading, code highlighting, code walkthroughs and program outputs. The book features 240 C++ applications with over 15,000 lines of proven C++ code, and hundreds of tips that will help you build robust applications. Start with an introduction to C++ using an early classes and objects approach, then rapidly move on to more advanced topics, including templates, exception handling, the Standard Template Library (STL) and selected features from the Boost libraries. You’ll enjoy the Deitels’ classic treatment of object-oriented programming and the OOD/UML® 2 ATM case study, including a complete C++ implementation. When you’re finished, you’ll have everything you need to build object-oriented C++ applications.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值