MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Is there a way to do comment with just one keystroke at the start

  • To: mathgroup at smc.vnet.net
  • Subject: [mg128718] Re: Is there a way to do comment with just one keystroke at the start
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Mon, 19 Nov 2012 19:18:39 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20121113050518.D63FE69AB@smc.vnet.net> <k7vevv$s52$1@smc.vnet.net>

On 14/11/2012 06:50, Murray Eisenberg wrote:
> On Nov 13, 2012, at 12:05 AM, Eric Rasmusen<erasmuse61 at 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




  • Prev by Date: Re: Subscript on plus expression
  • Next by Date: Re: Replace Rule for LaplaceTransform
  • Previous by thread: Re: Is there a way to do comment with just one keystroke at the start as
  • Next by thread: Re: Is there a way to do comment with just one keystroke at the start