";" is described under Compound Expression as a delimiter, such that only the output of the last item in the compund expression is given.
Situation:
1/ Print[] produces output whether followed by ";" or not. [Clearly an override is desirable so this makes sense for compound expressions]
2/ When combining graphics using Show[], appending ";" still suppresses output. Since "Show" is as conceptually active as "Print", is there a principle at work here (are there other instances)?
3/ If in procedural code a syntactically complete line is not terminated with a ";", the following line is indented... which means Show[] in the middle of several lines of code upsets indentation and code legibility
Question: if one has several graphics that one wishes to display without combining them what is the recommended approach, given that multiple Show[] should be separated by ";" but doing so suppresses output.
PS There is an incredibly minor-but-irritating-to-the-beginner "quirk" of commenting: semi-colon before comment at the end of code before a closing "]" is marked as a syntax error - is it really? If so, what is the nature of the error (it might just be redundant)?
Block[{a},
Print[a];(*the ; preceding is magenta, but is it really a syntax error?*)]
One is tempted to say the ";" is superflous because the expression is terminated by "]", in which case why is it not still an error when extra line breaks are inserted?
Block[{a}, Print[a];
(*the ; preceding is not magenta, so why is this not a syntax error?*)
]
Print[expr]
is different thanexpr
, evaluation will sendexpr
viaPrint
to$Output
. 2) If you havea;
,b
,c;
in consecutive lines in the cell then onlyb
will be printed. It is not aCompoundExpression
unless you wrap it with something, e.g:(a; b c;)
(each in new line) Take a look at first part of this answer too. $\endgroup$Print[Show[...]];
per line. UnlikePrint
,Show
has no side effects (at least not since the major changes in how graphics are handled in version 6). The magenta highlighting doesn't really indicate a syntax error, I'd rather consider it an error in the highlighting. If you find that highlighting irritating you could put the;
after the comment, add another;
after the comment or explicitly putNull
after it. As documenteda;b;
is actuallyCompoundExpression[a,b,Null]
... $\endgroup$Shows
areCompoundExpressions
I'd do(a; Return[b, CompoundExpression]; c;)
, if you really can't put it in a separate line. $\endgroup$