跳转至内容

Eiffel 编程

0% developed
来自维基教科书,开放的世界,开放的书籍

欢迎来到维基教科书上的Eiffel for Everyone

关于 Eiffel

[编辑 | 编辑源代码]

Eiffel 最初由Bertrand Meyer 开发,它拥有简洁且非常易读的语法。语言的许多设计原则都强调代码的可读性和可维护性。

由于出色地实现了语言特性,如多重继承泛型(尤其是受限泛型),在 Eiffel 中用更少的代码表达复杂的想法比其他编程语言更容易。强大的类型系统以及详尽的静态类型检查允许程序轻松扩展规模,并以其他语言难以实现的方式演进。

Eiffel 因为过于冗长而受到批评,并且很容易被某些结构的冗长所困扰(比如它的循环语句)。然而,我发现其他经常被吹捧为简洁的语言,尤其是 C 家族中的 Java 和 C++,在复杂类型的声明和使用中可能会非常冗长。

指导设计原则

[编辑 | 编辑源代码]
  • 一切皆对象
  • 契约式设计
  • 单入口,单出口
  • 开闭原则
  • 命令/查询分离

Eiffel 特性 - 语言的独特之处

[编辑 | 编辑源代码]
  Contracts and contract inheritance
  Rich set of assertions
  Multiple Inheritance
  Constrained Genericity
  Type-safe agents (also known as closures)
  Void Safety
  SCOOP (Simple Concurrent Object Oriented Programming)

类的解剖

[编辑 | 编辑源代码]

类的一部分

[编辑 | 编辑源代码]
   Eiffel Names
    Reserved words
    Notes or indexing
    Name
    Inherit
    create
    features
    more notes
    the end
  Features
    Attributes
    Functions
       The Uniform Access Principle
    Procedures
       Commands vs Queries

基础知识

[编辑 | 编辑源代码]
  Implementing Features
  Local Variables
  Creating objects
  Assignment
  Calling features
  Operators
  Expressions
  Copying Objects
  Comparing Objects
  Conditional control
     The if statement
     The inspect statement
  Iteration—looping
  Flow of Control
  Attachment Checking and Locals (e.g. if attached l_foo as al_foo then ... end)

基本类型

[编辑 | 编辑源代码]
  Expanded Types
    INTEGERs of Various Sizes
    REALs
    CHARACTERs
    BOOLEAN
  Reference Types
    ANY
    STRINGs
    DATE
  Containers
  What's required
  What's ensured
  Invariants: What is always true (about a class)
  Checks
  Variants and loop contracts
  Why its useful
  How it works
    LSP
  Renaming
  Redefining
  Undefining
  Extending
  Non-conforming inheritance
  Implementation inheritance
  Multiple inheritance
  Inheritance of Contracts
  With Containers
  With Algorithms
  Constrained Genericity
  Example: Hash tables
  
 Uses for tuples
 Returning multiple values from a function
 Named tuples
 As a way of iterating over containers
 Using agents
 Closed and Open Arguments
 Agent declarations

高级主题

[编辑 | 编辑源代码]
 Covariance and Anchored Types
 

非常高级的主题

[编辑 | 编辑源代码]
  Memory Management Details
     Garbage Collection Limitations
  Interfacing to Other Languages
  .Net Support
  Low-level Debugging
  

扩展阅读

[编辑 | 编辑源代码]
华夏公益教科书