I have a question concerning constants in eiffel. Well it's just a semantic issue but it has been bugging me for some time now and I just don't understand the concept of this speciality.
For a normal assignment you use :=
which makes total sense in a mathematical thinking because it's the mathematical sign for an assignment
But if we look at the definition of a constant:
feature
some_constant: INTEGER = 5
I just don't see why we use the equality sign there. Is there a certain reason? I would understand it the following way: We assign the value 5 to the constant but then why the boolean expression?
I hope someone can explain the concept behind this
You have to treat the =
sign as a quick contract for the constant feature.
foo: INTEGER = 5
would be identical to
foo: INTEGER
ensure
Result = 5
Note that this is a recent syntax change, before it used to be
foo: INTEGER is 5
but the Eiffel specification dropped the is
keyword altogether.