07eiffel - Eiffel Like the tower, emphasizing elegant...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Eiffel Like the tower, emphasizing elegant French design; developed by Bertrand Meyer The basic structure of object-oriented languages is the class a class is both 1) a module and 2) a type as a module : an interface (set of available services) & an implementation (information hiding) as a type : pattern for declaring variables or creating instances Eiffel emphasizes static type checking , performed by compiler Smalltalk and OO dialects in Lisp perform all type checking at runtime Objective-C as an added feature allows static typing, but not id Cox emphasizes that you want factory objects available at runtime C++ is statically typed, but preserves all the holes allowed by C-- what holes? Macros, unions, type casting, etc Eiffel’s design tries to extend the heritage of Pascal, Modula, Ada Goal is that the compiler should promote more reliable code Objects are run-time entities created during system execution Classes are static descriptions of a set of possible objects Compiler sees only classes; run-time system sees only objects What are the some tradeoffs of a strongly, statically typed language like Eiffel vs. a dynamically typed ("typeless") language like Smalltalk? security vs. flexibility knowledge about classes at run-time (metaclasses)--useful for OODB (C++ adds RTTI) Routines Suppose I have an object, Person, with provides a service, age In Pascal or C or Fortran, Person could provide this service in 2 ways: As data (in a field of a record): John.age As computation (result of a function ): age(John) What's the problem here? --Different syntax for same service Here's another one of Bertrand Meyer’s principles: a language should support services in a uniform way regardless of whether service is implemented through storage or computation e.g., john.age returns the feature age of object john -- age could either be stored or computed by a function (Meyer is also implicitly crowing at Bjarne Stroustrup here, because C++ does not support principle of uniform reference even if a member function has no parameters, you must use () to denote function) 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Two kinds of routines in Eiffel (like Pascal): a) procedures (effect instance, no result) b) functions (result, no side effects) Eiffel is somewhat purist about insisting that functions have no side effects e.g., input.readint is a procedure, not a function, because it has a side effect on input (input is an instance of class STD_FILE) since input.readint is a procedure, it does not return an integer; you need to use a function to actually get the value that readint just read Here's how to read an integer into a variable: local integer num; --declare a variable of type integer do --begin executable block input.readint; --procedure has a side effect num := input.lastint; --function returns a value end Comments? What do you think of this design? Clients and Suppliers
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/06/2008 for the course CSE 432 taught by Professor Blank during the Fall '08 term at Lehigh University .

Page1 / 8

07eiffel - Eiffel Like the tower, emphasizing elegant...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online