Difference between revisions of "Talk:New CAT call"
m |
|||
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | ''The most obvious observation is, that this weakens the new non-void typing mechanism, it is now possible to pass Void to feature f of class B2. This was probably not the intention of the programmer.'' - I do not understand this comment. Changing a:ANY into a:?STRING looks like a standard contravariant redefinition to me. Such redefinitions are sound. [[User:schoelle]] | + | ''The most obvious observation is, that this weakens the new non-void typing mechanism, it is now possible to pass Void to feature f of class B2. This was probably not the intention of the programmer.'' - I do not understand this comment. Changing a:ANY into a:?STRING looks like a standard contravariant redefinition to me. Such redefinitions are sound. --[[User:schoelle]] |
Changing ANY into STRING is covariance, changing STRING into ANY is contravariance--[[User:Manus|manus]] 18:38, 8 November 2006 (CET) | Changing ANY into STRING is covariance, changing STRING into ANY is contravariance--[[User:Manus|manus]] 18:38, 8 November 2006 (CET) | ||
Line 7: | Line 7: | ||
Changing ANY into ?STRING is not contravariance, it is covariance. Seeing it contravariant is possible a side effect of one of the interpretation of the current standard when looking at the semantic. I think we need another terminology here to describe this unspecified semantics.--[[User:Manus|manus]] 19:24, 9 November 2006 (CET) | Changing ANY into ?STRING is not contravariance, it is covariance. Seeing it contravariant is possible a side effect of one of the interpretation of the current standard when looking at the semantic. I think we need another terminology here to describe this unspecified semantics.--[[User:Manus|manus]] 19:24, 9 November 2006 (CET) | ||
− | Sorry, but I have to object: ANY into ?STRING '''is contravariant''': Any value of type ANY is a valid value of type ?STRING. AFAIK this is what contravariant means. I do not see any reason why we should invent a new name. --[[User:Schoelle|Schoelle]] 09:45, 15 November 2006 (CET) | + | Sorry, but I have to object: ANY into ?STRING '''is contravariant''': Any value of type ANY is a valid value of type ?STRING. AFAIK this is what contravariant means. I do not see any reason why we should invent a new name. Actually, all non-attached types are completely equivalent: they all can take any value. The type is only a hint for the create call and a comment. --[[User:Schoelle|Schoelle]] 09:45, 15 November 2006 (CET) |
+ | |||
+ | Do you mean ''local s: ?STRING; a: ANIMAL do s := a end'' is allowed (in general as opposed to the context of covariant redefinition)? I thought the semantic of ?X was "X or Void" that is basically the same as X in classic Eiffel. If we don't have a type to mean "X or Void" it seems like a severe flaw of the Void-checking side of things. --[[User:Nenieorg|Nenieorg]] 14:20, 22 February 2007 (CET) | ||
+ | |||
+ | :'''--[[User:Manus|manus]] 22:23, 22 February 2007 (CET)''' It is not allowed but depending on the semantics you give to the reattachment in the case of a catcall, it is as if you have contravariance. But currently although the standard is not clear on the subject, it is better to say it is Void rather than attached to the wrong type. | ||
+ | |||
+ | '''--[[User:Juliant|Juliant]] 09:46, 24 February 2007 (CET)''' | ||
+ | |||
+ | I would say <e>? STRING</e> means <e>STRING</e> or <e>Void</e>. ECMA talks about certified attachment patterns (chapter 8.24.10). Item 2 about the read-only entity says that you can use a detached type after a read-only void test: | ||
+ | <e> | ||
+ | local | ||
+ | e: ? STRING | ||
+ | do | ||
+ | if e /= Void then | ||
+ | e.to_lower | ||
+ | end | ||
+ | end | ||
+ | </e> | ||
+ | If you would be able to assign anything else than a <e>STRING</e> to a detached type <e>? STRING</e> then the void test would need to test types as well (which would make it equivalent to the object test). |
Latest revision as of 00:15, 24 February 2007
The most obvious observation is, that this weakens the new non-void typing mechanism, it is now possible to pass Void to feature f of class B2. This was probably not the intention of the programmer. - I do not understand this comment. Changing a:ANY into a:?STRING looks like a standard contravariant redefinition to me. Such redefinitions are sound. --User:schoelle
Changing ANY into STRING is covariance, changing STRING into ANY is contravariance--manus 18:38, 8 November 2006 (CET)
Changing ANY into ?STRING is contravariant. Could be STRING is more permissive than must be ANY as the first can contain any value, while the second may not contain Void. --Schoelle 10:01, 9 November 2006 (CET)
Changing ANY into ?STRING is not contravariance, it is covariance. Seeing it contravariant is possible a side effect of one of the interpretation of the current standard when looking at the semantic. I think we need another terminology here to describe this unspecified semantics.--manus 19:24, 9 November 2006 (CET)
Sorry, but I have to object: ANY into ?STRING is contravariant: Any value of type ANY is a valid value of type ?STRING. AFAIK this is what contravariant means. I do not see any reason why we should invent a new name. Actually, all non-attached types are completely equivalent: they all can take any value. The type is only a hint for the create call and a comment. --Schoelle 09:45, 15 November 2006 (CET)
Do you mean local s: ?STRING; a: ANIMAL do s := a end is allowed (in general as opposed to the context of covariant redefinition)? I thought the semantic of ?X was "X or Void" that is basically the same as X in classic Eiffel. If we don't have a type to mean "X or Void" it seems like a severe flaw of the Void-checking side of things. --Nenieorg 14:20, 22 February 2007 (CET)
- --manus 22:23, 22 February 2007 (CET) It is not allowed but depending on the semantics you give to the reattachment in the case of a catcall, it is as if you have contravariance. But currently although the standard is not clear on the subject, it is better to say it is Void rather than attached to the wrong type.
--Juliant 09:46, 24 February 2007 (CET)
I would say ? STRING
means STRING
or Void
. ECMA talks about certified attachment patterns (chapter 8.24.10). Item 2 about the read-only entity says that you can use a detached type after a read-only void test:
local e: ? STRING do if e /= Void then e.to_lower end end
If you would be able to assign anything else than a STRING
to a detached type ? STRING
then the void test would need to test types as well (which would make it equivalent to the object test).