Why is there only line-comment in WML?

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Why is there only line-comment in WML?

Post by WhiteWolf »

Hi,

I have been wondering lately, why is there only line-commenting available in WML, and are no block-comments?
I mean comments like in C:

Code: Select all

/*
This is a long comment
It can contain long comment parts of code without me having to # every bloody line, and is rather convenient for separating code during testing
and debugging
...
*/

// This is a line comment we have now with #
Is it only me who missed how to do this in WML, or is it really missing?
If it can be done, then with what syntax? :D If it can't, then why is it missing?
Even in mainline code I sometimes see chucks of code commented out with each #line, sometimes through dozens of lines. Burns my eyes. :D

Best regards,
WhiteWolf
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Why is there only line-comment in WML?

Post by gfgtdf »

yes there is onyl one-line commnets, but if you want to comment out long clode blocks the reccoemnded way is to wrap them in a #ifdef _unused__ ..code... #endif
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Why is there only line-comment in WML?

Post by WhiteWolf »

Well, I agree that using #ifdef _unused_ yields the same result, but it is not identical to a block-comment.
I guess it's not a priority, but would it be hard or or would it take long to implement some kind of block-comment to WML? Any kind of syntax, but I think it would really come in handy :)
Thanks
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Why is there only line-comment in WML?

Post by Sapient »

The syntax you proposed doesn't really fit with the rest of the language though.

I think your best option would be to use an editor that supports block commenting and uncommenting via keyboard shortcuts.

(This is the same situation as Python BTW)
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
The_Gnat
Posts: 2217
Joined: October 10th, 2016, 3:06 am
Contact:

Re: Why is there only line-comment in WML?

Post by The_Gnat »

I have found #ifdef to be effective, but i agree with whitewolf. It hasn't really bothered me though, if you really... really must comment out large amounts of code (probably for testing) than you can always just cut them and past them in a new file until you've finished your testing. As for placing huge comments, if you have time to write big comments than you have time to put a # at the start of each line :D
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Why is there only line-comment in WML?

Post by Sapient »

Personally I don't like the #ifdef trick. Maybe using a macro could make it look better.

Another thing that I remember zookeeper used to do was surround an entire block with [comment][/comment]. It's a nice trick, but the engine could complain about it depending on where you put it.

Consider also if you should be using git so that you can simply delete that code without worrying about losing it. That is far preferable to keeping the file cluttered with swathes of dead code.

Finally, there are so many editors that can do block comments, if that is something you really need there is really not any excuse for coding in Notepad. Sorry if I'm repeating myself here but it could help a lot to switch to a decent editor.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Why is there only line-comment in WML?

Post by zookeeper »

Sapient wrote:Another thing that I remember zookeeper used to do was surround an entire block with [comment][/comment]. It's a nice trick, but the engine could complain about it depending on where you put it.
Yeah, in most places (that is, anywhere I've ever needed to) you can just use bogus tags to hide the contents, although they will still be subject to the preprocessor (which can be desirable or not, depending on situation). So it's really only suitable for commenting out existing code, not for non-code comments as such.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: Why is there only line-comment in WML?

Post by WhiteWolf »

I currently use Pluma for all of my coding, it's an editor with the older interface of gedit, (a gedit fork), where it still had magical functions. Like...undo. I know gedit can do block-comments, but its new looks is just horrible. It's literally missing the 'undo' button. :annoyed: However, I can't get Pluma to do it for some reason, it doesn't load the Code Comment plugin, and doesn't seem to be accepting the Snippets plugin either. (Using Debian 8 with MATE environment, I'd be thankful for hints on this).
I would still prefer code-built block comments, since then those could be spotted easily while using WML-syntax highlighting. It's possibly just my freak style, but I find it more convenient. Nor #ifdef trick, nor [comment], nor a macro wouldn't be able to do that.

I can't get to like Notepad++, and vi or vim or emacs are on the other hemisphere. Sorry :(
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
The_Gnat
Posts: 2217
Joined: October 10th, 2016, 3:06 am
Contact:

Re: Why is there only line-comment in WML?

Post by The_Gnat »

Maybe a new pre-processor definition could be made for example #remove, and #endremove and everything between them could just be ignored.
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Why is there only line-comment in WML?

Post by gfgtdf »

I personally think that #ifdef __unused__ is much better for disabling code than some other comment syntax would be. I don't code much wml but in C++ i always use #ifdef 0, .. #endif over /* ... */ for commenting out nontrivial codeblocks, in lua i always use if false then .. end over --[[ ... ]] if possible for commenting out nontrivial codeblocks. It makes it more clear that is actuall still code and not just some text commant, and it also enables the syntax highighting & autointention of the editor to make that diabled code easier to read. Also it makes it easily possible to activate this code by just chanign one line, since i can just replace false by true, and don't have to change the block ender
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
Pentarctagon
Project Manager
Posts: 5565
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Why is there only line-comment in WML?

Post by Pentarctagon »

I second having comment blocks like

Code: Select all

/*
stuff
*/
for syntax highlighting.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
The_Gnat
Posts: 2217
Joined: October 10th, 2016, 3:06 am
Contact:

Re: Why is there only line-comment in WML?

Post by The_Gnat »

Well the way i see it is: if its easy to add a multi-line comment (less than 2 hours of work) than it would be very good to have this feature at some point. If its not easy than there really is no point in prioritizing this above other more needed bug fixes and features.

A multi-line comment would be nice, but it is not a necessity.
Post Reply