MathGroup Archive 2008

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

Search the Archive

Re: Mathematica commenting of code using (* *) can't be nested

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84986] Re: Mathematica commenting of code using (* *) can't be nested
  • From: David <habud at hotmail.com>
  • Date: Tue, 22 Jan 2008 01:50:25 -0500 (EST)
  • References: <200801191101.GAA18691@smc.vnet.net> <47921293.1000102@math.umass.edu> <fmv0u4$2hb$1@smc.vnet.net>


Nasser Abbasi wrote:
> ----- Original Message ----- 
> From: "Murray Eisenberg" <murray at math.umass.edu>
> 
> 
>> Without a second right-end *) to match, I think this should obviously be 
>> treated as a syntax error.
>>
> 
> I think Mathematica is free to have its language rules of course, I was just 
> commenting because that is NOT how other languages normally treats comments 
> that has an opening and closing tokens.
> 
> Once a comment is started, everything in from of it is ignored until the 
> comment is closed.
> 
> This works in C:       /*  comment   /*  still inside a commant   */
> This work in C++:    //  comment   //  still inside a commant   //
> This does NOT work in Mathematica  (*  comment  (*  still inside a comment 
> *)

Your comparing a compiled language with an interpreted lanquage. C has 
other mechanisms for preprocessing sections of code that Mathematica 
doesn't have. And, your C++ example "//" is only a single line comment. 
That doesn't compare (apples-to-apples) with a block comment like "(*...*)".

For example:
What if you have a code fragment that is within another code fragment?

(* Code Fragment 1:
Module[
....
   (* Code Fragment 1.1:
   Module[
   ...
   ]
   *)
*)

I can uncomment either fragment without parsing issues. With your 
implementation, that wouldn't be possible. I think Mathematica's 
implementation is perfectly logical.

> 
> Nasser 
> 
> 


  • Prev by Date: 2D Interpolation
  • Next by Date: Re: How remove CellChangeTimes values?
  • Previous by thread: Re: Re: Mathematica commenting of code using
  • Next by thread: Re: Mathematica commenting of code using (* *) can't be nested well.