From SmartEiffelWiki

What you need to know about Current

The object model is fundamental to Eiffel. All instructions written in Eiffel are always in the context of a given object, the object which is affected by the active method, the current object, denoted simply by Current.

As you may already have noticed, Eiffel code is always written inside a particular class. Either the code is in a method that necessarily is in a particular class; or else, when it is not in a method, it is because it is in the invariant of a particular class, the class of the current object, the class of Current.

So, from the very fact that Eiffel code is being executed, there must always exist a particular, accessible Current object. This approach of organising your code around particular objects is one of the strongpoints of Eiffel, a fundamental aspect of the object approach.

Among the things that you have to keep in mind about Current is that Current always designates an object. In other words, Current is never Void. In fact, another essential point about Eiffel is that it is not possible to trigger a method if there is no object. You will know this if you have already read the section on dynamic dispatch: it is the very nature of the object, its dynamic type, which allows it to select the most appropriate code. Thus, not only does Current always designate an object, but furthermore the code being executed is the code which is best suited to Current.

It goes without saying, considering what has just been said, that it would be risky, to say the least, to be able to change the type of Current while a method is executing. Imagine if, for example, you were running a method in the POINT class and you subsituted for the current POINT object, Current, an object of the TRIANGLE class! Fortunately, this is not possible and, in order to avoid completely any possibility of such chaos, changing the value of Current, that is, using Current on the left of an assignment, is strictly forbidden.

To conclude this section on Current, let us say that the equivalent notation in Smalltalk is self and the idea called this in C++ and Java is similar.

Other languages