Taking Eiffel for a Spin

Lately I’ve been playing around with a multitude of languages, hoping to not only have yet more to add to my list of fluent languages to brag about, but to also gain further insight in other implementations and design from them. For this reason, I decided to play with Eiffel over the weekend.

Eiffel is a rather interesting language with a multitude of interesting features. It’s well known that it is organized around concepts of Design By Contract, which allow you to explicity set preconditions and postconditions for method calls, as well as invariants (more on that later). For example, say I have a class Employee who (for whatever reason) cannot be younger than 18 or older than 60.


feature
	age:INTEGER
	set_age(a:INTEGER) is
		require
			a >= 18 AND a <=60
		do
			age := a
		end

Another feature I equally liked is the concept of agents, which felt more or less like an object oriented version of a loop. Basically, say I have a collection of people and, for each person, I want to call some object method to calculate their interest rate.


people.do_all(agent calc.calculate_interest(?))

There are plenty of other interesting features to talk about, such as generics, multiple inheritence, and the Command-query seperation principle, but I am currently pressed for time. Don't worry, I'll follow up... this is definiately going to be my "language of the week" this week. ;)

You can leave a response, or trackback from your own site.

Facebook comments:

3 Responses to “Taking Eiffel for a Spin”

  1. Nit Picker says:

    Shouldn’t your age restriction (a >= 18 and a

  2. Nit Picker says:

    PS. It looks like the < symbol broke my previous post…

  3. James Carr says:

    Yeah that’s not good… looks like it was chopped off before the comment went into the database… guess I’ll have to fix that. ;)

Leave a Reply

Subscribe to RSS Feed Follow me on Twitter!