Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Is there a way to do comment with just one keystroke at the start as
Replies: 2   Last Post: Nov 19, 2012 7:18 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
David Bailey

Posts: 714
Registered: 11/7/08
Re: Is there a way to do comment with just one keystroke at the start
Posted: Nov 19, 2012 7:18 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 14/11/2012 06:50, Murray Eisenberg wrote:
> On Nov 13, 2012, at 12:05 AM, Eric Rasmusen<erasmuse61@gmail.com> wrote:
>>
>> The standard way to do comments in Mathematica is like this
>> (*Here is a comment*)
>>
>> In Latex, a short comment only takes one symbol, at the start of the line:
>> %Here is a latex comment
>>
>> Is there a way to comment in Mathematica without the closing symbols? is there an any easy way to make a macro to imitate latex comments?

>
> Sorry, but that's the way it is.
>
> Of course you could use Text cells instead of embedding comments inside an Input cell.
>
> That won't work, of course, if you need to insert comments within (too?)-long code in an Input cell. In the latter case, you could try the following:
>
> Comment[blah___] := Null
>
> For example:
>
> Comment["first we do this"]
> 1 + 1
> Comment[next]
> x + 2
> Comment[]
>


Unfortunately, this breaks for certain comment positions:

In[809]:= Comment[blah___] := Null

In[810]:= Sin[Comment["angle"] Pi]

Out[810]= Sin[Null \[Pi]]

Possibly a slightly better version would be:

Comment[blah___] := Sequence @@ {}

However, even that will fail if used inside Hold[...], and probably in
other situations as well, so I don't advise using it.

I think a UNICODE character reserved for comment out of one line would
be a valuable feature, and maybe also a pair of characters equivalent to
(* and *), which are IMHO very ugly!

David Bailey
http://www.dbaileyconsultancy.co.uk





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.