mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-07 07:12:25 +01:00
Author:halw
Date:2009-08-26T22:00:15.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@289 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -250,9 +250,29 @@ This would be fine in ''workbench'' code, but what happens if the code is ''fina
|
||||
The answer is that the <code>check</code> remains in force in finalized code, because it is necessary to prove void-safety.
|
||||
|
||||
|
||||
|
||||
==Stable attributes==
|
||||
|
||||
|
||||
Remember that stable attributes are actually detachable attributes, with the difference that they can never be the target of an assignment in which the source is <code>Void</code> or anything that could have a value of <code>Void</code>.
|
||||
|
||||
Stable attributes are useful in situations in which there are valid object life scenarios in which some particular attribute will never need an object attached, or will only need an object attached late in the scenario. So in this case, the attribute is used only under certain runtime conditions. Declaring these attributes as stable eliminates the need to make attachments during object creation. Yet once needed, that is, once the attribute is attached, it will always be attached.
|
||||
|
||||
Also, you should remember that unlike other attributes, you can access stable attributes directly in a CAP:
|
||||
<code>
|
||||
my_stable_attribute: detachable SOME_TYPE
|
||||
note
|
||||
options: stable
|
||||
attribute
|
||||
end
|
||||
|
||||
...
|
||||
|
||||
if my_stable_attribute /= Void then
|
||||
my_stable_attribute.do_something
|
||||
end
|
||||
|
||||
...
|
||||
</code>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ where <code>x</code> is the formal argument for <code>r</code>, then if x is of
|
||||
|
||||
===Stable attributes===
|
||||
|
||||
Stable attributes are really stable ''detachable'' attributes, as adding the concept of stability is meaningful only for detachable attributes. Declaring a detachable attribute as stable, means that it behaves like a detachable attribute except that its assignment rules mimic those of attached attributes. In other words, a stable attribute does not need to be attached upon creation like attached attributes do. But like attached attributes, stable attributes can never be the target of an assignment in which the source is <code>Void</code> or a detachable type.
|
||||
Stable attributes are really stable ''detachable'' attributes, as adding the concept of stability is meaningful only for detachable attributes. Declaring a detachable attribute as stable, means that it behaves like a detachable attribute except that its assignment rules mimic those of attached attributes. In other words, a stable attribute does not need to be attached during object creation the way that attributes declared as attached must. But like attached type attributes, stable attributes can never be the target of an assignment in which the source is <code>Void</code> or a detachable type.
|
||||
<code>
|
||||
my_test: detachable TEST
|
||||
note
|
||||
@@ -209,9 +209,9 @@ Stable attributes are really stable ''detachable'' attributes, as adding the con
|
||||
end
|
||||
</code>
|
||||
|
||||
This means that even though stable attributes do not need to be initialized like attached attributes, once they are attached to an object, they can never be void again.
|
||||
This means that even though stable attributes do not need to be initialized like attributes of attached types, once they are attached to an object, they can never be void again.
|
||||
|
||||
Stable attributes are also interesting in that they are the only exception to the rule given in the [[Void-safety: Background, definition, and tools#Certified Attachment Patterns (CAPs)|CAPs section]] above that said that access to attributes cannot be protected by a CAP. A stable attribute can be used under the protection of a CAP. This is because once a stable attribute has an object attached, it can never again be set to <code>Void</code>. So there's no worry about having the attribute's state going from attached to non-attached because of the actions of other routines or threads.
|
||||
Stable attributes are also interesting in that they are the only exception to the rule given above in the [[Void-safety: Background, definition, and tools#Certified Attachment Patterns (CAPs)|CAPs section]] that stated that direct access to attributes cannot be protected by a CAP. A stable attribute can be used under the protection of a CAP. This is because once a stable attribute has an object attached, it can never again be set to <code>Void</code>. So there's no worry about having the attribute's state going unexpectedly from attached to non-attached because of the actions of other routines or threads.
|
||||
|
||||
===Rule for generic parameters===
|
||||
|
||||
|
||||
@@ -22,9 +22,17 @@ In network-style client-server communication, the mechanism will be dissymmetric
|
||||
A software system will exchange objects with another by sending them to a socket. Although if you stay at the predefined level you will not need to manipulate sockets explicitly, it is useful to understand this concept and know about the corresponding EiffelNet classes.
|
||||
|
||||
You may think of a socket as a communication port; by attaching sockets together you enable communication between the corresponding systems, for example a client and a server:
|
||||
|
||||
|
||||
[[Image:fig-2]]
|
||||
|
||||
|
||||
EiffelNet has been designed so that sockets look very much like files. You send objects to a socket in the same way that you write objects onto a file, and receive objects from a socket in the same way that you read objects from a file. This fundamental commonality is reflected in the inheritance hierarchy of the corresponding classes:
|
||||
|
||||
|
||||
[[Image:fig-3]]
|
||||
|
||||
|
||||
Note that the hierarchy as shown is not complete; in particular the full structure uses classes STREAM (of which the <code> STREAM_ </code> classes are heirs) and <code> DATAGRAM </code> for multiple inheritance ''. ''Only the classes below the dotted line are part of EiffelNet; the others are part of EiffelBase, the fundamental data structure and algorithm library of ISE Eiffel [ [[Bibliography|2]] ].
|
||||
|
||||
The most important property of this inheritance hierarchy is that it shows how sockets fit within the overall structure. Thanks to the common ancestor <code>IO_MEDIUM</code>, socket classes have most of their features in common with files.
|
||||
@@ -66,7 +74,7 @@ As documented in [ [[Bibliography|2]] ], <code>STORABLE</code> provides features
|
||||
struct1.independent_store (iom1)
|
||||
</code>
|
||||
|
||||
Assuming that the type of ''iom1 ''is <code>IO_MEDIUM</code> or a conforming type such as [[ref:libraries/base/reference/file_chart|FILE]] or one of the <code>_SOCKET</code> classes, and that the type of ''struct1'' conforms to <code>STORABLE</code> ''.''Note that reference [2] in its original version does not include ''independent_store'', and requires ''iom'' to be of type FILE rather than the more general <code>IO_MEDIUM</code>. The current version of EiffelBase, however, supports the more general properties described here.
|
||||
Assuming that the type of ''iom1 ''is <code>IO_MEDIUM</code> or a conforming type such as [[ref:libraries/base/reference/file_chart|FILE]] or one of the <code>_SOCKET</code> classes, and that the type of ''struct1'' conforms to <code>STORABLE</code>. Note that reference [2] in its original version does not include ''independent_store'', and requires ''iom'' to be of type FILE rather than the more general <code>IO_MEDIUM</code>. The current version of EiffelBase, however, supports the more general properties described here.
|
||||
|
||||
All three storage procedures have the effect of sending to ''iom1 ''(whether a file, a socket or some other IO-medium) a copy of the entire object structure starting at ''struc1''. Together with the retrieval routines seen below, they apply the principle of reference completeness stated in [ [[Bibliography|1]] ] and [ [[Bibliography|2]] ]:
|
||||
{| border="1"
|
||||
@@ -106,10 +114,3 @@ EiffelNet supports a highly asynchronous (and hence efficient) mode of operation
|
||||
* Using <code>POLL_MASK</code>, you can set a mask to select the sockets or files on which your instance of <code>MEDIUM_POLLER</code> is working.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user