RE: newbie Comment question

• To: mathgroup at smc.vnet.net
• Subject: [mg47028] RE: [mg47018] newbie Comment question
• From: "David Park" <djmp at earthlink.net>
• Date: Mon, 22 Mar 2004 05:18:40 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```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
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

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

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.

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/

```

• Prev by Date: RE: Question on Ordering
• Next by Date: Re: Manipulating the Front End
• Previous by thread: Re: newbie Comment question