Re: RE: RE: simple question
- To: mathgroup at smc.vnet.net
- Subject: [mg77294] Re: [mg77161] RE: [mg77113] RE: [mg77099] simple question
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Wed, 6 Jun 2007 07:19:06 -0400 (EDT)
- References: <200706031015.GAA03008@smc.vnet.net> <17807603.1180947440083.JavaMail.root@m35> <op.ttd8jwb7qu6oor@monster.ma.dl.cox.net> <200706051035.GAA00766@smc.vnet.net> <20010005.1181048860294.JavaMail.root@m35> <op.ttgliznnqu6oor@monster.ma.dl.cox.net>
*This message was transferred with a trial version of CommuniGate(tm) Pro* On 6 Jun 2007, at 02:29, DrMajorBob wrote: > Isn't that a powerful argument against converting to traditional > form -- ever? -- since the same thing happens when the original > code is Sin[x], which converts to sin(x) and then becomes sin x > (multiplication) when pasted back into Mathematica? I would not say "ever" because I use Traditional Form for output (and often for Input) in all the classes I teach and in everything I print, but certianly you should never distribute or share with others any notebooks (not to mention packages) in Traditional Form. Even for archival purposes it is better to store notebooks in Standard Form, since that is much less likely to be subject to changes in future releases of Mathematica. However, the point of my observation about comments was a bit different: I think comments whether in notebooks or in packages should be completely "inactive" and never change at all when you perform evaluations or change format of cells etc. As far as I know only text strings have this property. With notebook interface there is another possiblity: using Text cells for comments, but then it is better to make them non-editable so they can't be accidently converted to input cells and end up getting evaluated. But again, this will work only if you stay within Mathematica and use the notebook interface. There is also another problem which affects Ingolf style Comments and unfortunately also string comments. Compare these two definitions: f[x_] := Sin[a x(*a is a parameter*) ] g[x_] := Sin[a x ; Comment[a is a parameter] ] h[x_] := Sin[a x; "a is a parameter"] {f[Pi], g[Pi], h[Pi]} {Sin[a*Pi], Sin[Comment[a^2*is*parameter]], Sin["a is a parameter"]} Of course you can avoid this but I think it demonstrates that the proposed solutions are all much less convenient than having proper comments. Andrzej Kozlowski > > Bobby > > On Tue, 05 Jun 2007 08:06:15 -0500, Andrzej Kozlowski > <akoz at mimuw.edu.pl> wrote: > >> *This message was transferred with a trial version of CommuniGate >> (tm) Pro* >> Try the folowing. First enter >> >> Comment[" This is my comment. "] >> >> into na input cell. Now use the Convert To menu in the Cell menu >> to convert the cell into Traditional Form. Next, copy and paste >> into some text editor (it could even be another copy of >> Mathematica running on the same machine) and then copy it again an >> paste it back into a new cell in (the original) Mathematica. Now >> evalaute the cell. You will probably now agree that "This is my >> comment." is preferable. >> >> Andrzej Kozlowski >> >> >> On 5 Jun 2007, at 19:35, Ingolf Dahl wrote: >> >>> Yes, from execution point of view, >>> >>> "This is my comment." >>> >>> works as well as >>> >>> Comment[" This is my comment. "]; >>> >>> but comments are meant for human readers of the program, and I >>> think that my >>> proposal is better for informing the reader that the comment >>> really is a >>> comment and nothing else. It is also easier for a metaprogram to >>> find, >>> delete, print, color or translate all such comments inside a >>> program. >>> Another way is of course to decorate the comment strings in some >>> way, for >>> instance >>> >>> "(***** This is my comment. *****)" . >>> >>> Matter of taste... >>> About not capitalizing user-defined functions, I think that that >>> is a good >>> rule, if some exceptions are allowed. For instance, package >>> authors usually >>> seem to capitalize their "user-defined" functions. And if I >>> suggest this >>> natural use of the word "Comment", it is implicitly an appeal to >>> Wolfram not >>> to use the same word for something else. If many users adopted >>> the practice, >>> they could even include it as an alternative in the Help. >>> >>> Best regards >>> >>> Ingolf Dahl >>> >>>> -----Original Message----- >>>> From: DrMajorBob [mailto:drmajorbob at bigfoot.com] >>>> Sent: den 4 juni 2007 12:54 >>>> To: Ingolf Dahl; mathgroup at smc.vnet.net >>>> Subject: Re: [mg77113] RE: [mg77099] simple question >>>> >>>> I believe "This is my comment." works just as well, without >>>> the comment function. (I never capitalize user-defined functions.) >>>> >>>> Bobby >>>> >>>> On Mon, 04 Jun 2007 02:46:35 -0500, Ingolf Dahl >>>> <ingolf.dahl at telia.com> >>>> wrote: >>>> >>>>> Hi Dimitris, >>>>> I cite from mg64218 (Feb 7, 2006), thread "Notebooks, >>>> packages, cells, >>>>> and literate programming": >>>>> >>>>> "One alternative way to enter inline comments, if you anyway want >>>>> that, is to wrap them up in a ordinary Mathematica function in >>>>> this >>>>> way: >>>>> >>>>> Comment[" This is my comment. "]; >>>>> >>>>> There usually are any number of places in the code where >>>> you could add >>>>> comments in this way. If you have not defined the function >>>>> Comment, >>>>> the statement will not be evaluated. Such comments are not >>>> removed by >>>>> Shift-Ctrl-N or Shift-Ctrl-I. >>>>> Of course I must here also remind that the button >>>> "CopyAsInputForm" in >>>>> my SetFaceAndFont Palette preserves (* *) comments by >>>> converting them >>>>> into the suggested alternative. (See >>>>> http://web.telia.com/~u31815170/Mathematica/)" >>>>> >>>>> The palette is not updated to version 6 yet, since I just have had >>>>> Mathematica 6 available a few days, but this feature seems to be >>>>> functioning. >>>>> >>>>> Best regards >>>>> >>>>> Ingolf Dahl >>>>> >>>>>> -----Original Message----- >>>>>> From: dimitris [mailto:dimmechan at yahoo.com] >>>>>> Sent: den 3 juni 2007 12:15 >>>>>> To: mathgroup at smc.vnet.net >>>>>> Subject: [mg77099] simple question >>>>>> >>>>>> Hi. >>>>>> >>>>>> I have a simple question but I can't find any relevant. >>>>>> Suppose a user-defined function with comments [that is >>>>>> (*...*) structures] added. >>>>>> >>>>>> Let for example >>>>>> >>>>>> \!\(Nint[g_ (*function*) , n_Integer, {x_, a_, b_} (* >>>>>> the\ variable\ and\ the\ limits\ >>>>>> of\ integration*) , opts___ (*set\ possible\ >>>> options\ for\ \ >>>>>> NIntegrate*) ] := NIntegrate[Evaluate[g\^Range[n]], {x, a, b}, >>>>>> opts]\) >>>>>> >>>>>> The code has been copy/paste in StandardForm. >>>>>> Let me convert it to InputForm. After selecting the cell and >>>>>> press >>>>>> Shift+Ctrl+I, I get >>>>>> >>>>>> In[1]:= >>>>>> Nint[g_, n_Integer, {x_, a_, b_}, opts___] := >>>>>> NIntegrate[Evaluate[g^Range[n]], {x, a, b}, opts] >>>>>> >>>>>> That is, the comments during the conversion have been lost. >>>>>> >>>>>> Any ideas to "fix" this situation? >>>>>> >>>>>> Dimitris >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> DrMajorBob at bigfoot.com >>> >>> >>> >> >> > > > > -- > DrMajorBob at bigfoot.com
- References:
- simple question
- From: dimitris <dimmechan@yahoo.com>
- RE: RE: simple question
- From: "Ingolf Dahl" <ingolf.dahl@telia.com>
- simple question