Interesting. cmd+’ doesn’t work for me. Anyone else? Maybe dead key keyboard related problem?
i use // if I am inserting the comment.
’ is generally from the IDE marking code as a comment.
many ask for the /* */ code blocks, but I am not sure if I care for them. I wouldnt complain if they are put in but I dont think I would use them.
well it is late and I have been up 20hrs now so time to go to bed before I say something completely unintelligent.
good night all
So, nobody uses REM ?
// I still use REM in my Windows build .bat files…
I didn’t even know it would work!
That mode was great in C when you needed to comment out large blocks of code /* at the beginning and the */ at the end - done.
However, Selecting a region and then hitting CMD-’ makes even that seem like too much work :).
I use // as the start of some section related to program logic, and ’ to make a remark or clarification about some line of code.
[quote=15189:@Tim Jones]That mode was great in C when you needed to comment out large blocks of code /* at the beginning and the */ at the end - done.
However, Selecting a region and then hitting CMD-’ makes even that seem like too much work :).[/quote]
I’ve never used /* */ for commenting out code. But it is my preferred method of producing in code documentation. That is why I would like to see that or something similar.
I use // as the start of some section
In that case, I skip some empty lines (3 to 5), and add - by group of 10 + 1 space - 40 to 80 ---------- characters:
// ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
// The part below lies with blah, blah, blah, blah, blah,
and so on. Less # of '---------- ’ means less important code in the part.
Of course, the loveliest my code looks like when I watch it, the better I feel. I remember advices about commenting your code:
c. Comment and Comment ad nauseam: in some months or more, you will be happy to read the comments !
Another Command was: save, save and save (today we can also say Backup, Backup, and Backup !)
I too would like to vote for /* and */ for block comments, That is what is used in RPGIV and since I bounce between the two languages that would be handy.
Wouldn’t this do the same thing for you?
#if FALSE These are comments in my code. The compiler will never check these lines so I can type anything at all. #endif
They could probably implement within the IDE that the text will be colored like a comment if the only condition for an “#if” is “false”. They wouldn’t need to change the compiler at all.
The #if FALSE trick would work for compilation, but I’ll bet the editor would get in the way. For example, type if, then, while or something in your text, it will surely be highlighted and possibly cause indentation problems.
Oooh… I feel a feature request coming on here Currently at the end of the line you can press Shift-Return and it will complete all sorts of things, such as If TrueSHIFT-Return, you’ll wind up with a full If/Then/End If clause. What if Shift-Return would automatically create a new line and prefix it with the comment character used on the current line? i.e.
// Hello worldSHIFT-RETURN
// Hello World
Actually using #if False is nice for blocks of code because it retains it’s indentation & colorization
About the only time you get weird effects is if you have to do something like
[code] #if TargetMacOS
if someConditionThatsOnlyPossibleOnAMac then
// some code here
and this is perfectly fine code BTW
Only if I was commenting out blocks of code in which case I would use CTRL + ’ as I would not want it highlighted as then it would look like live code in the IDE. For me at least having a comment look like anything but a comment is a reduction in efficiency.
[quote=15247:@Norman Palardy]Actually using #if False is nice for blocks of code because it retains it’s indentation & colorization
About the only time you get weird effects…[/quote]
But the original op was talking about using #If False… #end if to provide block comments to document code, so he may have something like:
[code]#if False then
This function does XYZ. It’s parameters are:
- Blah - String - does this or that
- Blah2 - Integer - why have it? Blah
Actually, I use a number of special types of mechanically-added comments (such as " '/ ") for particular situations, but here are two generalizations:
(1) I prefer " // " (double slashes) over " ’ " (aopostrophes), because the former is more visible for me.
*(2) I use " /// " (triple slashes) for “permanent” remarks (that I don’t want to be ever removed. such as acknowledment of indebtedness to authors who gave permission for me to use – and to distribute – particular routines they had written and " // " (double slashes) for “temporary” remarks I intend to remove before the final version.
[quote=14325:@Christian Schmitz]// for things I do for real comments.
And ’ with the IDE command to disable blocks of code.[/quote]
In non RS/Xojo Basic type code I have generally used '- for ordinary comments. The - being mostly to improve the visibility of the comment marker. I also have used '* and '# for more significant comments.
In languages which support // I tend to use that and for more significant comments I use //* or //#
( I have used /// in c# as it is used for auto-documentation in that language, so I don’t use it elsewhere as I’m easily confused ! )
I prefer // on each line to /* … */ in most cases.
I prefer the #if … #endif method for disabling code
But what about if you want to comment several as many other modern languages, is there a way to do it here in Xojo???