15.06.2013 Views

Dispensa in PDF - Dipartimento di Scienze Ambientali, Informatica e ...

Dispensa in PDF - Dipartimento di Scienze Ambientali, Informatica e ...

Dispensa in PDF - Dipartimento di Scienze Ambientali, Informatica e ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Carnielli Efrem: Programmazione a componenti<br />

Pr<strong>in</strong>cipi <strong>di</strong> progettazione<br />

collega gli activation record agli ambienti statici <strong>di</strong> appartenenza delle variabili.<br />

L'esempio della fig. 3.4 sta ad <strong>in</strong><strong>di</strong>care che se <strong>in</strong> più funzioni utilizzo una stessa<br />

variabile x, ognuna <strong>di</strong> queste avrà un suo scope, cioè un suo ambiente, la static<br />

cha<strong>in</strong> mi serve a capire qual'è l'ambiente corretto per ogni x.<br />

Supponiamo <strong>di</strong> avere il seguente frammento <strong>di</strong> co<strong>di</strong>ce:<br />

f(){<br />

f(){<br />

<strong>in</strong>t <strong>in</strong>t x;<br />

x;<br />

h(){<br />

h(){<br />

<strong>in</strong>t <strong>in</strong>t <strong>in</strong>t y;<br />

y;<br />

}<br />

g();{<br />

g();{<br />

h();<br />

h();<br />

x++;<br />

x++;<br />

}<br />

g(x);<br />

g(x);<br />

}<br />

54

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!