x is allowed to be a local variable or formal argument only. That is, x may not be an attribute or general expression (with one exception which we will see below). Direct access to class attribute references cannot be allowed via a CAP due to the fact that they could be set to void by a routine call in some execution path invoked by the intervening instructions or possibly even different process thread. In a later section, we well see that this is not quite such a limitations as it may appear at this point."if x /= Void then -- ... Any other instructions here that do not assign to x x.f (a) end
Il me semble qu'après le "x /= Void", on peut tout à fait mettre à Void la variable x de la même façon que pour un attribut et ceci avec un exemple "idiot" :
if x /= Void then -- ... Any other instructions here that do not assign to xx := Void x.f (a) end
J'ai du passer totalement à coté de l'explication fournie dans la doc...Merci d'avance pour vos lumières.
Jocelyn B.
--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes Groupe des Eiffelistes Francophones.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse groupe_eiffelistes_fr...@googlegroups.com.
Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .
Here are the tools of void-safe trade. They will each be addressed in more detail throughout the documentation that follows. As you look at these elements it helps to try to think about things from the compiler's viewpoint ... after all, it is the compiler that we expect to give us the guarantee that our code is indeed void-safe.
First let's look at a couple of approaches that won't work.
It might occur to us that we could enforce compliance with the target rule by simply eliminating the concept of void references. But this would not be practical. Void is a valuable abstraction that is useful in many situations, such as providing void links in structures. So, we must keep void ... but we want to keep it under control.
Another thought might be that we could just have the compiler do all the work for us. But would be impossibly time consuming for the compiler to investigate every conceivable execution path available to a system to make certain that every possible feature call was made on an attached reference.
So, all of this boils down to the fact that we have to take some actions that help the compiler along. That's what the following are about.
We know that in the context of certain code patterns, it is clear that it would be impossible for a reference to be void. These patterns are identified and we call them CAPs, short for Certified Attachment Patterns. Here is a very straightforward example expressed in a syntax that should be familiar to all Eiffel developers:
if x /= Void then -- ... Any other instructions here that do not assign to x x.f (a) end
x is not void. Then as long as no assignments to x are made in the interim, a feature f can be applied to x with the certainty that x will be attached at the time ... and importantly, this can be determined at compile time. So, we say that this code pattern is a CAP for x.
It is important to understand that in this example (and with other CAPs), x is allowed to be a local variable or formal argument only. That is, x may not be an attribute or general expression (with one exception which we will see below). Direct access to class attribute references cannot be allowed via a CAP due to the fact that they could be set to void by a routine call in some execution path invoked by the intervening instructions or possibly even different process thread. In a later section, we well see that this is not quite such a limitations as it may appear at this point.
Ce que je ne comprends pas c'est donc (sans les notions "attached/detachable" puisque ce raisonnement doit amener à la construction du concept) quelle différence entre un attribut de classe et variable locale avec l'exemple de base "if x /= Void" ?
Merci d'avance.
Jocelyn B.
Bonjour,
Je ne comprends pas le sens de cette discussion. L’affectation avec un “Void caché”…
Dans l’extrait de documentation sur les CAP, vous avez copié/collé ceci notamment :
if x /= Void then
-- ... Any other instructions here that do not assign to xx.f (a)
end
Selon le commentaire, les instructions
après le then ne contiennent aucune affectation de x.
Le commentaire en dit long… et répond à
votre question. N’est-ce pas ?
Cordialement,
Paul G. Crismer
--