[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Liberty-eiffel] user-friendly real constants
From: |
Laurie Moye |
Subject: |
[Liberty-eiffel] user-friendly real constants |
Date: |
Thu, 01 Jan 2015 16:55:00 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
Hi,
Is this really the behaviour of a user friendly compiler:-
************************************************
class TEST_REAL
creation {ANY}
run
-------------------------------------------------------------------------------
feature {ANY} -- Public features
run is
local
r_32 : REAL_32
do
r_32 := 1.234
end
-------------------------------------------------------------------------------
end -- class TEST_REAL
************************************************
ceres/test_r32: compile test_real -o test_real
****** Fatal Error: Bad assignment. Cannot assign `1.234' which
is of type REAL_64 into `r_32' which is of type REAL_32.
The source lines involved by the message are the following:
Line 12 columns 4, 12 in TEST_REAL
(/home/laurie/lib/Eiffel/liberty/args/test_r32/test_real.e):
r_32 := 1.234
^ ^
------
Error occurs while compiling. Compilation process aborted.
************************************************
Shouldn't the compiler have a look at 1.234 to see what is the smallest
real that it will fit into, and seeing that it will fit into a REAL_32
put it into one so that it can be assigned to a REAL_32, then it can be
promoted if it has to be assigned to a REAL_64 or larger?
This seems to be what happens in the case of integers.
Best wishes,
Laurie
- [Liberty-eiffel] user-friendly real constants,
Laurie Moye <=