Bug - Fixed comments in plural typed strings

ckb

Minion
Staff member
Not sure if this is truly a bug or just a way strings work, but you cannot add in-line comments to plural typed strings in the same way you can with other data types.
Easy to work around, but it makes me sad when I cannot add comments to make things pretty.

This code:
PHP:
	foreach it in $items[
	seal tooth,
	helmet turtle, //this is a comment
	turtle totem, //and another one
	saucepan,
	] { print(it); }
	
	print("-");
	
	foreach ss in $strings[
	seal tooth,
	helmet turtle, //this is a comment
	turtle totem, //and another one
	saucepan,
	] { print(ss); }

Yields this result:
Code:
seal tooth
helmet turtle
turtle totem
saucepan
-
seal tooth
helmet turtle
//this is a commentturtle totem
//and another onesaucepan
 

Veracity

Developer
Staff member
That is intentional.

Code:
			allowComments = type.getBaseType().getType() != DataTypes.TYPE_STRING;
I don't know why. I'll either figure out why - and agree with it - or will remove that restriction.
 

Veracity

Developer
Staff member
Code:
foreach ss in $strings[
    seal tooth,
    helmet turtle \//this is not a comment\, ha ha,
    turtle totem, //and another one
    saucepan,
    ] { print(ss); }
yields (with relaxing that restriction) the following:

Code:
seal tooth
helmet turtle //this is not a comment, ha ha
turtle totem
saucepan
Given that you can escape slashes and commas, I see no problem with stripping comments from plural string constants.

Revision 19991
 
Top