Inform code blocks

Having just spent a few months programming a ROBLOX game in LUA, I return to my I7 project and find I’m slightly bothered by the inability to add some gratuitous whitespace in the middle of code blocks. You know, a line ending in a semicolon must have the next line immediately below it, that kind of thing.

I’m guessing there’s probably some good reason for this. For those who might know, is there, and what is it?

-Wade

1 Like

Whitespace is meaningful in Inform, both indentation (the tabs to set off code blocks) and line breaks (one line between statements, two lines between rules). If it helps, you can put a [] comment line in between if you want—as long as it’s not two line breaks in a row, it’ll be okay.

3 Likes

So it’s as simple as that it can’t guess around line breaks and indentation too much? That makes sense.

Thanks for the comment idea.

-Wade

1 Like

A line ending in a semicolon does not necessarily have to have the next line immediately below it. You can write your entire code without ever using periods/full stops, instead just ending code blocks with another semicolon. I adopted this partway through my perpetual WIP, since if I want to add or move code I don’t have to worry about errors. But you cannot have a (normal) double line break in the middle of a code block (e.g. rulebooks, if statements), though if you need one, you might want to consider restructuring your code to be more readable.

2 Likes

I don’t think I realised until you said this that you could even end some declarative sentences with semicolon. I was pretty sure that used to not compile:

e.g. Bedroom is east of lab;

…but I could be wrong.

Though this is a place I don’t want to use a semicolon. Usually I have a bunch of declarations in a line, and I like to end those with periods.

This isn’t my problem, though. What I’d want to do is separate ideas or bits in the middle of one block, like this:

	now Korhva wears c5-kshoes;
	now Korhva wears c5-kblouse;
	now Korhva wears c5-kpants;
	
	let HOLOTHING OUTCOME be dataitem in row 10 of table of anacdata2;
	now c5-ship-choice-as-number of Korhva is dataitem in row 11 of table of anacdata2;

And it’s not possible to just put in a line break like in what I pasted. But you can poke in an open comment, end comment, which has the same visual separation effect:

	now Korhva wears c5-kshoes;
	now Korhva wears c5-kblouse;
	now Korhva wears c5-kpants;
	[
	]
	let HOLOTHING OUTCOME be dataitem in row 10 of table of anacdata2;
	now c5-ship-choice-as-number of Korhva is dataitem in row 11 of table of anacdata2;

-Wade

1 Like
when play begins:
  let x be 1;
;
  increment x;

A bare ; works (but can’t immediately follow a :, i.e., it doesn’t work for a blank first line.

3 Likes

This is even better (slightly) than the blank comments trick.

-Wade

And since the IDE allows us to set a specific color for comments, it makes the code even easier to read by marking complex blocks with small colored squares that separate the different steps.

2 Likes