liberty-eiffel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Liberty-eiffel] reverse-assigment problem


From: Cyril ADRIAN
Subject: Re: [Liberty-eiffel] reverse-assigment problem
Date: Sat, 24 Jan 2015 15:38:54 +0100

Hi,

By default, classes insert ANY. There is no conformance relationship. In particular, STRING does not conform to ANY.

See http://wiki.liberty-eiffel.org/index.php/Papers#Non-Conforming_Inheritance:_the_SmartEiffel_Experiment_of_a_High-Level_Mechanism -- paragraph 3.6

See also http://wiki.liberty-eiffel.org/index.php/Typing_policy

Cheers,

Cyril

2015-01-23 17:11 GMT+01:00 Laurie Moye <address@hidden>:
Hi,

Here is a structure that I used successfully in SmallEiffel, but it
won't compile in Liberty.
*****************************
class TEST_REVERSE_ASSIGNMENT [ G ]

create {ANY}
   make

feature {ANY}           -- Public features
   make (g : G) is
      local
         s : STRING
      do
         s ?= g
         io.put_string(s)
      end

-------------------------------------------------------------------------------
end                     -- class TEST_REVERSE_ASSIGNMENT
*****************************
class RUN_TEST

create {ANY}
   run

feature {ANY}           -- Public features
   run is
      local
         string_thing : TEST_REVERSE_ASSIGNMENT[ STRING ]
      do
         create string_thing.make("Hello World%N")
      end

-------------------------------------------------------------------------------
end                     -- class RUN_TEST
*****************************
The attempt to compile gives:
*****************************
ceres/liberty-conversion: compile -boost -no_gc run_test -o run_test
****** Fatal Error: Invalid assignment attempt ("?="). The left-hand
side _expression_ must conform to the right-hand side. The _expression_
`s' is of type STRING while the _expression_ `g' is of type ANY.

The source lines involved by the message are the following:

Line 11 columns 4, 9 in TEST_REVERSE_ASSIGNMENT
(/home/laurie/rbs/liberty-adler/from-SE-0.75/liberty-conversion/test_reverse_assignment.e):
         s ?= g
         ^    ^
------
Error occurs while compiling. Compilation process aborted.
*****************************
I don't understand this. Surely _everything_ conforms to ANY?
It works if I declare:
class TEST_REVERSE_ASSIGNMENT [ G -> HASHABLE ]
or (I assume) any of the many other classes inherited by STRING.

Searching to see if I could find anything about this online, the only
thing I came up with is that "x ?= y" has been abandoned in ECMA-367 and
marked as obsolete in EiffelStudio. Is there some other mechanism I
should be using?

Best wishes,
          Laurie




reply via email to

[Prev in Thread] Current Thread [Next in Thread]