15.07.2013 Views

jgrasp handbook

jgrasp handbook

jgrasp handbook

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Consider the fragment at right with s(1)<br />

and s(2) in the body of the if statement.<br />

After the CSD is generated, the reader<br />

can see how the compiler will interpret<br />

the code, and add the missing braces.<br />

Here is another common mistake made<br />

glaring by the CSD.<br />

Most likely, the semi-colon after the<br />

condition was unintended. However,<br />

the CSD shows what there rather than<br />

what was intended.<br />

Similarly, the CSD provides the correct<br />

interpretation of the while statement.<br />

.<br />

Missing braces . . .<br />

Similarly, the CSD provides the correct<br />

interpretation of the while statement.<br />

Unintended semi-colon . . .<br />

Reading Correctly with the CSD<br />

s(1);<br />

if (cond)<br />

s(2);<br />

s(3);<br />

¨¹¹Ïs(1);<br />

Ï ¨¹³´if (cond)<br />

Ï §Ï¾¹¹Ïs(2);<br />

Ï ¨¹¹Ïs(3);<br />

if (cond);<br />

s(2);<br />

s(3);<br />

Ï ¨¹(¹if (cond);<br />

Ï ¨¹¹Ïs(2);<br />

Ï ¨¹¹Ïs(3);<br />

while (cond)<br />

s(2);<br />

s(3);<br />

Ï §<br />

ÏϨ¹¹±while (cond)<br />

ÏϧÏÏй¹Ïs(2);<br />

ÏϨ¹¹Ïs(3);<br />

Ïϧ<br />

while (cond);<br />

s(2);<br />

s(3);<br />

ϧ<br />

ÏϨ¹¹#while (cond);<br />

ÏϨ¹¹Ïs(2);<br />

ÏϨ¹¹Ïs(3);<br />

Ïϧ<br />

DRAFT, February 18, 2003, Page 41

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

Saved successfully!

Ooh no, something went wrong!