Author:halw

Date:2011-09-19T03:37:05.000000Z


git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@977 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
halw
2011-09-19 03:57:52 +00:00
parent 6fc9a28f22
commit 034b4b45ed

View File

@@ -158,7 +158,7 @@ Before we get into an example of convertibility, let's list some of its underlyi
Let's look at an example that may already be familiar to you.
<code>
my_string: STRING
my_string: STRING_8
my_system_string: SYSTEM_STRING
@@ -166,21 +166,21 @@ Let's look at an example that may already be familiar to you.
my_string := my_system_string
</code>
In the snippet above, we have attributes declared of type <code>STRING</code> and <code>SYSTEM_STRING</code>.
In the snippet above, we have attributes declared of type <code>STRING_8</code> and <code>SYSTEM_STRING</code>.
We know that if we have a attribute of type <code>STRING</code> that we can make a direct assignment of a .Net type of string (that is, the .Net type <code>System.String</code> which we see as class <code>SYSTEM_STRING</code>) to our <code>STRING</code> attribute.
We know that if we have a attribute of type <code>STRING_8</code> that we can make a direct assignment of a .Net type of string (that is, the .Net type <code>System.String</code> which we see as class <code>SYSTEM_STRING</code>) to our <code>STRING_8</code> attribute.
We know also that <code>SYSTEM_STRING</code> does not conform to <code>STRING</code>, so according to the definition of [[ET: Instructions#Assignment and attachment|compatibility]], this must happen through conversion.
We know also that <code>SYSTEM_STRING</code> does not conform to <code>STRING_8</code>, so according to the definition of [[ET: Instructions#Assignment and attachment|compatibility]], this must happen through conversion.
Therefore <code>SYSTEM_STRING</code> converts to <code>STRING</code>. And according to the definition above this means that either:
Therefore <code>SYSTEM_STRING</code> converts to <code>STRING_8</code>. And according to the definition above this means that either:
# Class <code>SYSTEM_STRING</code> has a conversion query listing <code>STRING</code> as a conversion type, or
# Class <code>STRING</code> has a conversion procedure listing <code>SYSTEM_STRING</code> as a conversion type
# Class <code>SYSTEM_STRING</code> has a conversion query listing <code>STRING_8</code> as a conversion type, or
# Class <code>STRING_8</code> has a conversion procedure listing <code>SYSTEM_STRING</code> as a conversion type
In this case <code>STRING</code> has a conversion procedure for objects of type <code>SYSTEM_STRING</code>. Conversion procedures are always [[ET: The Dynamic Structure: Execution Model#Creating and initializing objects|creation procedures]]. So they appear in both the <code>create</code> and the <code>convert</code> parts of the class.
In this case <code>STRING_8</code> has a conversion procedure for objects of type <code>SYSTEM_STRING</code>. Conversion procedures are always [[ET: The Dynamic Structure: Execution Model#Creating and initializing objects|creation procedures]]. So they appear in both the <code>create</code> and the <code>convert</code> parts of the class.
<code>
class STRING
class STRING_8
create
make_from_cil
@@ -204,16 +204,16 @@ is equivalent to:
create my_string.make_from_cil (my_system_string)
</code>
So, we've seen how <code>SYSTEM_STRING</code> converts to <code>STRING</code>. But, in the context of our example, we could also do this:
So, we've seen how <code>SYSTEM_STRING</code> converts to <code>STRING_8</code>. But, in the context of our example, we could also do this:
<code>
my_system_string := my_string
</code>
Which means that <code>STRING</code> converts to <code>SYSTEM_STRING</code>. The <code>convert</code> part of class <code>STRING</code> also has a conversion query listing <code>SYSTEM_STRING</code> as a conversion type:
Which means that <code>STRING_8</code> converts to <code>SYSTEM_STRING</code>. The <code>convert</code> part of class <code>STRING_8</code> also has a conversion query listing <code>SYSTEM_STRING</code> as a conversion type:
<code>
class STRING
class STRING_8
create
make_from_cil