Janos,
Comments in Mathematica are inserted using (* .... *). So you could use...
line1;
(* line2; *)
line3;
However, in my humble opinion, comments in Mathematica are poorly
implemented and, except for commenting out, are almost totally useless. In
package code they cause parsing errors. If you convert an Input Cell from on
Form to another, say from StandardForm to InputForm, the comments are thrown
away.
Weaving some comments into code is a very useful and proper programming
practice. Text cell comments are in no way a substitute for this. Comments
should be considered as part of the proper syntax of all Input cells. They
should not be thrown out when converting between various input Forms. The
parser should handle comments simply by skipping over them.
This is a long standing incorrectly implemented feature of Mathematica.
I would like to point out another, this time good feature of Mathematica
that many are unaware of. It is very convenient to do a calculation with
multiple input lines in one cell. It is also easy to add comments in the
form of Print statement so that you have commented output. You can use the %
and %% expressions quite safely within a single cell. You can use
statement1; and still refer to its output as %. Here is a simple example of
commented output.
Print["Starting equation"]
a x + b == c
Print["Subtract b from both sides"]
# - b & /@ %%
Print["Divide by a"]
#/a & /@ %%
If you close up the Input cell, using Alt-C-R-C, your notebook will have
just the commented output. This is very convenient for displaying
derivations in Mathematica.
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
From: János [mailto:janos.lobb at yale.edu]
To: mathgroup at smc.vnet.net
I have lines and lines of codes. Like
line1;
line2;
line3;
I would like to comment out line2 temporary. How do I do it ? I tried
to look hard in the Book last night, but found nothing.
Related question. If I do not want to insert a text cell to explain
what a line does, how can I add comments to the lines ?
In other languages /*....*/ or // would work, but not here. I do not
know yet how to add text cells, but would like to comment the code I
do.
Thanks ahead,
János
-------------------------------------------------
clear perl code is better than unclear awk code; but NOTHING comes
close to unclear perl code
http://www.faqs.org/faqs/computer-lang/awk/faq/