Author:halw

Date:2009-10-28T02:00:10.000000Z


git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@340 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
halw
2009-10-28 02:00:10 +00:00
parent c3934411d1
commit c14d26b0fb
3 changed files with 11 additions and 11 deletions

View File

@@ -49,7 +49,7 @@ First make sure your project will compile correctly under the configuration of E
Then set the project setting '''Full Class Checking''' to '''True'''. Do a ''clean'' compile of your system. To do this shut down EiffelStudio, and restart it. When the project selection dialog appears, select your project, then next to '''Action:''' select '''Compile''' in the drop-down, and check '''Clean'''.
Full class checking will analyze your classes to make sure that in cases of inheritance features of the parent classes are recheck for validity in the heirs.
Full class checking will analyze your classes to make sure that in cases of inheritance, features of the parent classes are rechecked for validity in the heirs.
Here's an example of the kind of error you might expect when compiling with full class checking:
@@ -67,7 +67,7 @@ create
If we go to the <code>create</code> part of <code>NVP_LIST</code> and add <code>make_sublist</code> to its list of creation procedures, this will fix the problem:
<code>
create
make, make_from_string, make_from_file_named, make_sublist
make, make_from_string, make_from_file_named, make_sublist
</code>
So, fix any problems that arise out of turning on full class checking.
@@ -328,10 +328,6 @@ To support the "empty array" design, <code>segment_start</code>'s postcondition
</code>
===Using generic classes===
{{SeeAlso|[[Converting EiffelVision 2 Systems to Void Safety]]}}

View File

@@ -73,16 +73,16 @@ This change works for all the generic classes in EiffelBase ... except for one:
</code>
we create <code>my_array</code> with one hundred <code>INTEGER</code> elements. <code>INTEGER</code> is an expanded type, and each element is initialized by applying the default initialization rule for <code>INTEGER</code>, i.e, the integer representation of zero.
However, if <code>my_array</code> had been declared of a type with reference semantics, say <code>STRING</code> (meaning, or course, <code>attached STRING</code>, the default rule would not work well, because the default initialization for references types is <code>Void</code>.
However, if <code>my_array</code> had been declared of a type with reference semantics, say <code>STRING</code> (meaning, or course, <code>attached STRING</code>, the default rule would not work well, because the default initialization for references types is <code>Void</code> which would not be allowed in an array of elements of any attached type.
The solution to this challenge is fairly simple. For arrays of elements of detachable or expanded types, there is no different behavior. For arrays of elements of attached types, then we must be careful.
The solution to this challenge is fairly simple. For arrays of elements of detachable or expanded types, there is no different behavior. When dealing with arrays of elements of attached types, we must be careful.
Creating an array using <code>ARRAY</code>'s creation procedure <code>make</code> may still be safe in some cases. Specifically, <code>make</code> can be used with arrays of elements of attached types if the arguments have values such that an empty array will be created, that is, when
<code>
min_index = max_index + 1
</code>
In all other situations involving arrays of elements of attached types, it is not safe to use <code>make</code> to do the creation. Rather, you should use the creation procedure <code>make_filled</code> which takes three arguments. The first is an object of the type of the array, and the second and third are the minimum and maximum indexes, respectively. When the array is created, each of the elements will be initialized with a reference to the object of the first argument.
In all other situations involving arrays of elements of attached types, <code>make</code> may not be used to do the creation. Rather, you should use the creation procedure <code>make_filled</code> which takes three arguments. The first is an object of the type of the array, and the second and third are the minimum and maximum indexes, respectively. When the array is created, each of the elements will be initialized with a reference to the object of the first argument.
So, a call using <code>make_filled</code> would look like this:
<code>
@@ -106,7 +106,7 @@ The complete attached syntax is:
</code>
In this section, we will see more ways in which to use this versatile language facility.
===As a CAP which yields a local variable===
===As a CAP-like construct which yields a local variable===
In the introduction to the attached syntax, we used an example which showed how the attached syntax is directly relevant to void-safety. That is, the code:
<code>

View File

@@ -263,7 +263,11 @@ In the case of an actual generic parameter of an attached reference type, all th
<code>
create my_array.make_filled ("", 1, 100)
</code>
The third argument is an object of the actual generic type, in this case an empty <code>STRING</code>. Every entry in the newly created <code>ARRAY</code> will be initialized to reference this object.
The first argument is an object of the actual generic type, in this case an empty <code>STRING</code>. Every entry in the newly created <code>ARRAY</code> will be initialized to reference this object.
For more detail on void-safe use of arrays and other generic classes, see the section: [[Creating a new void-safe project#Using generic classes|Using generic classes]].