Advertisement

Sri Lanka's First and Only Platform for Luxury Houses and Apartment for Sale, Rent

Wednesday, August 10, 2011

Eiffel Programming

As part of degree studies I had to learn a Programming Language named Eiffel which enables to write programs which doesn't unintentionally kill or injure people/assets. Simply put it enables to write Secure programs.

The Eiffel language many features to make this possible such as Design by Contract, Multiple Inheritance, Method Rename and so on.

While doing Eiffel I wanted to try out a Small thread based code I did in Java in Eiffel. The code just takes in a String and prints one character after another in the console like in those Action Movies where the secret location name will be printed.

After some reading I managed to do this with the following code in Eiffel.

slow_prompt(text : STRING) is

require
valid_text : text /= void
local
counter : INTEGER
do
from
counter := 1;
until
counter > text.count
loop
io.put_character (text.at (counter));
sleep(7812500); -- Sleep for 7812500 nano seconds
counter := counter + 1;
end
end


For this method to work however the class EXECUTION_ENVIRONMENT needs to facility inherited.

No comments: