From cd2f778fa5fed51076d57db0bd31ea980f6bac28 Mon Sep 17 00:00:00 2001 From: halw Date: Fri, 16 Sep 2011 21:27:55 +0000 Subject: [PATCH] Added section on assignment and attachment Author:halw Date:2011-09-16T21:27:55.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@973 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../eiffel-tutorial-et/et-instructions.wiki | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/documentation/current/method/eiffel-tutorial-et/et-instructions.wiki b/documentation/current/method/eiffel-tutorial-et/et-instructions.wiki index adfafd5d..07ab85e1 100644 --- a/documentation/current/method/eiffel-tutorial-et/et-instructions.wiki +++ b/documentation/current/method/eiffel-tutorial-et/et-instructions.wiki @@ -5,6 +5,33 @@ Eiffel has a remarkably small set of instructions. The basic computational instructions have been seen: creation, assignment, assignment attempt, procedure call, retry. They are complemented by control structures: conditional, multi-branch, loop, as well as debug and check. +===Assignment and attachment=== + +As noted above we have already introduced assignment. But let's take another look at the assignment in the context of the more abstract concept of '''attachment'''. Attachment can occur with reference types by assignment such as: + + x := y + +In this assignment, x is the target of the assignment and y is the source. The object associated with y becomes ''attached'' to the entity x. + +Attachment also occurs when actual arguments are substituted for formal arguments in a call to a routine. + + f (w) + +In the call to f above, the object associated with the actual argument w will be ''attached'' to the formal argument for the duration of the execution of f. So, in this case, w can be viewed as the source of the attachment and the formal argument of f is the source. + +We learned in the section on [[ET: Inheritance#polymorphism|polymorphism]], that the type of the source of an assignment must conform to the type of the assignment's target. + +The rule that governs validity of assignments expands upon this and is generalized to apply to all attachments. + + +{{Rule|name=Assignment|text=An assignment is valid if and only if the type of its source expression is '''compatible''' with the type of its target entity. }} + + +The phrase "'''compatible with'''" in this rule means that either it "'''conforms to'''" or "'''converts to'''". + +We saw conformance defined in the section on [[ET: Inheritance#polymorphism|polymorphism]]. [[ET:Other Mechanisms#convertibility|Convertibility]] is explained in the section on [[ET:Other Mechanisms#convertibility|Other Mechanisms]]. + + ===Conditional=== A conditional instruction has the form