rem
this is a comment line
so is this
endrem
this line is code though
Its only a small example BUT imagine if you have a hundred line piece of code you wish to change just a quick rem..endrem would work wonders or some command similar


Code: Select all
CompilerIf 0
This is 1 line of a block comment...
And so is this but you have To deal With autoformatting. :(
CompilerEndIf
+1MachineCode wrote:CompilerIf works, but the comments are formatted incorrectly (as skywalk said), and the commented block is not in the IDE's comment color. So, it's not really a good solution.
Block comments are perfect for commenting out an entire procedure or set of procedures, so you can try alternates without losing the original.Shield wrote:Nothing against block comments, but please not with rem / endrem...![]()
Then again they are not needed anyway. (At least myself, I never use them in any language to comment something).
+1 on this -- but I'd make it more "purebasic-ish"Tenaja wrote: I agree; Rem EndRem are not good, but something more "pb-like" would be CommentStart/End. (Although I would much rather type /* */, because it is shorter and common vernacular.
Code: Select all
; This is a single line comment
;{
this is a multiline
comment
;}
Yes, but only for that. If they are actively used to actually comment the source they are nothingTenaja wrote: Block comments are perfect for commenting out an entire procedure or set of procedures...
What? If you comment out a procedure, then you also need to comment out all calls to that procedure; otherwise you'll get an error when trying to compile.Tenaja wrote:Block comments are perfect for commenting out an entire procedure or set of procedures, so you can try alternates without losing the original.
Code: Select all
/*
blah
/*
old blah
*/
*/
Oh, I see. In that case, it's easier to just rename the old procedure instead, rather than commenting it all out. Just add an extra single char to the start of the procedure name, to make it redundant.Shield wrote:Not if he replaces the procedure by an alternative, as he said (same name, probably directly below the old procedure).
Actually, using the characters of C and Java do NOT mean it is not nestable. The ability to nest block comments is entirely up to the compiler author. It is actually quite easy to "upgrade" block comments to allow nesting, no matter WHAT character set you use to start it. This text below shows how to do it very easily with one-character, but with two or more characters, it is trivially different:Shield wrote:Not if he replaces the procedure by an alternative, as he said (same name, probably directly below the old procedure).
The problem with block comments is, if they are implemented as in C#, C++, Java, ... that they are not nestable,
which means commenting out block comments, e.g.
is not possible without removing the previous */. So please...make them nestable.Code: Select all
/* blah /* old blah */ */
There's one last item to deal with: nested comments. Some programmers like the idea of nesting comments, since it allows you to comment out code during debugging. The code I've given here won't allow that and, again, neither will Turbo Pascal.
But the fix is incredibly easy. All we need to do is to make SkipComment recursive:
Code: Select all
{ Skip a comment field } procedure SkipComment; begin while Look <> '}' do begin GetChar; if Look = '{' then SkipComment; end; GetChar; end;
That does it. As sophisticated a comment-handler as you'll ever need.