[eiffel-users] Why the problem with types?

classic Classic list List threaded Threaded
3 messages Options
jjj
Reply | Threaded
Open this post in threaded view
|

[eiffel-users] Why the problem with types?

jjj
I do not understand why I get "source of assignment is not compatible with target" in the following setup:
----------------------------------------------------------------------------
Class: JJ_RAND [G -> JJ_NATURAL]
Feature: forth_with_interval
Target name: rem
Target type: [detachable like item] detachable Generic #1
Source type: attached JJ_NATURAL
Line: 23
        rng := a_upper - a_lower
->      rem := value.max_value \\ rng
      end

The classes follow.  In `forth_with_interval' the first statement compiles, why not the second.

deferred class
JJ_RAND [G -> JJ_NATURAL]
feature -- Access
item: G
-- Just return something for testing.
do
Result := value
end
value: like item
deferred
end
forth_with_interval (a_lower, a_upper: like item)
-- Move index to ..."
local
rng: like item  -- range
rem: like item  -- remainder
do
rng := a_upper - a_lower
rem := value.max_value \\ rng
end
end

class
JJ_RAND_64
inherit
JJ_RAND [NATURAL_64]
feature -- Access
value: NATURAL_64 = 5489
-- The default value used for the `seed'.
end


--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [eiffel-users] Why the problem with types?

'Alexander Kogtenkov' via Eiffel Users
Most probably either JJ_NATURAL.max_value or `\\` returns JJ_NATURAL rather than `like Current`. Because JJ_NATURAL does not conform to G, you get this error.

Regards,
Alexander Kogtenkov


jjj <[hidden email]>:

I do not understand why I get "source of assignment is not compatible with target" in the following setup:
----------------------------------------------------------------------------
Class: JJ_RAND [G -> JJ_NATURAL]
Feature: forth_with_interval
Target name: rem
Target type: [detachable like item] detachable Generic #1
Source type: attached JJ_NATURAL
Line: 23
        rng := a_upper - a_lower
->      rem := value.max_value \\ rng
      end

The classes follow.  In `forth_with_interval' the first statement compiles, why not the second.

deferred class
JJ_RAND [G -> JJ_NATURAL]
feature -- Access
item: G
-- Just return something for testing.
do
Result := value
end
value: like item
deferred
end
forth_with_interval (a_lower, a_upper: like item)
-- Move index to ..."
local
rng: like item  -- range
rem: like item  -- remainder
do
rng := a_upper - a_lower
rem := value.max_value \\ rng
end
end

class
JJ_RAND_64
inherit
JJ_RAND [NATURAL_64]
feature -- Access
value: NATURAL_64 = 5489
-- The default value used for the `seed'.
end

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.
jjj
Reply | Threaded
Open this post in threaded view
|

Re: [eiffel-users] Why the problem with types?

jjj
Yes, that was the problem.  Thanks.

On Wednesday, May 3, 2017 at 5:50:57 AM UTC-4, Alexander Kogtenkov wrote:
Most probably either JJ_NATURAL.max_value or `\\` returns JJ_NATURAL rather than `like Current`. Because JJ_NATURAL does not conform to G, you get this error.

Regards,
Alexander Kogtenkov


jjj <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="2ioa57VkAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jjj...@...>:

I do not understand why I get "source of assignment is not compatible with target" in the following setup:
----------------------------------------------------------------------------
Class: JJ_RAND [G -> JJ_NATURAL]
Feature: forth_with_interval
Target name: rem
Target type: [detachable like item] detachable Generic #1
Source type: attached JJ_NATURAL
Line: 23
        rng := a_upper - a_lower
->      rem := value.max_value \\ rng
      end

The classes follow.  In `forth_with_interval' the first statement compiles, why not the second.

deferred class
JJ_RAND [G -> JJ_NATURAL]
feature -- Access
item: G
-- Just return something for testing.
do
Result := value
end
value: like item
deferred
end
forth_with_interval (a_lower, a_upper: like item)
-- Move index to ..."
local
rng: like item  -- range
rem: like item  -- remainder
do
rng := a_upper - a_lower
rem := value.max_value \\ rng
end
end

class
JJ_RAND_64
inherit
JJ_RAND [NATURAL_64]
feature -- Access
value: NATURAL_64 = 5489
-- The default value used for the `seed'.
end

--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
Visit this group at https://groups.google.com/group/eiffel-users.
For more options, visit https://groups.google.com/d/optout.