Individual properties: impact on size?

Reading about individual properties it seems that that the “Property individual foo” syntax exists just to make sure that a property name will be valid, even if no objects assign anything to it.

However, when I add “Property individual foo” (as opposed to omitting it and just starting to use it on objects), my file size increases by ~100 bytes.

Is that expected? If I know I’m going to use a property anyway, is there any reason to declare them as individual?

Common properties are limited to 62 in the game file, and the standard library uses about 50. Individual properties are not limited.

Right, @zarf, but my question is about “declared as individual properties” vs “used without predeclaration”:

Property individual declared;

Object Cat
with
declared 100,
spontaneous 200,
;

Is there any reason to pre-declare as individual (besides the case of “you can’t have that refers to them using ‘provides’ unless they’re pre-declared or appear on at least one object). I don’t care about the refer-to-undefined, since I’m not building a library; every thing I use “provides” on will have at least one usage on an object).

And is it correct that pre-declaring them as individual (as opposed to just using them without predeclaration) should increase the file size?

Thanks!

Does the file size increase persist if you strip out debug names and labels? By default, Inform story files include various metadata about properties, arrays, variables, and so on, which are used to print sensible runtime error messages. You can tell the compiler not to do that by setting $OMIT_SYMBOL_TABLE to 1 in !% comments or on the command line.

Thanks, @Draconis . I’m already omitting the symbol table (and using several other “smaller file size” features).

It looks like pre-declaring a property as “individual” costs ~50 bytes as opposed to just starting to use it without any declaration.

I don’t care that much about the 50 bytes — but seeing the file size change makes me feel like I’m not understanding the distinction between pre-declared-as-indiv properties and just-used-without-declaration properties. I may be misunderstanding @zarf and @fredrik on the github comments, but I thought that pre-declaring as individual only has one difference: you don’t get an error if you say stuff like “x provides myprop” and never had an object that that property on it.

Are pre-declared individual props faster?

I fail to reproduce your results. This is the source I use to test:

!% -~S
!% $OMIT_UNUSED_ROUTINES=1
!% $ZCODE_LESS_DICT_DATA=1
!% $LONG_DICT_FLAG_BUG=0
!% $OMIT_SYMBOL_TABLE=1
!% $ZCODE_MAX_INLINE_STRING=4000
!% $ZCODE_COMPACT_GLOBALS=1

Constant Story      "N";

Constant RUNTIME_ERRORS = 0; ! 0, 1 or 2. 0 = smallest file, 2 = most info

Constant INITIAL_LOCATION_VALUE = Library;

Include "globals.h";
Include "puny.h";

!Property individual flubber;


Object Library "L" with description "D"
!, flubber 7
;

Constant Initialise = 0;

I compile with:

inform6.exe +lib nada.inf -v5es

If the individual property is neither declared nor used: 23916 bytes
If it is declared but not used: 23916 bytes (and I get a warning, as I should)
If it is declared and used: 23928 bytes
If it is used but not declared: 23928 bytes

Pre-declared individual props aren’t faster. Once compiled, they aren’t different from non-declared individual props in any way, as far as I know.

3 Likes

Yeah, as far as I know the Property individual syntax is just because of me—I was frustrated with the inability to use individual properties in I6-within-I7, because the compiler couldn’t figure out the types properly, so I pushed for some way to do that. My understanding was that it had no effect at all in Inform 6 proper, except possibly adding an entry to the symbol table.

1 Like

Thanks @fredrik , I really appreciate your digging with me on this. I get the same results as you. Of course, my real file is much bigger and has a more complex build process, so the size difference may just be other things, and nothing to worry about here.

I did get the clear answer that I wanted: as long as you don’t care about using-an-never-set prop, the pre-declare and did-declare are the same.

I suspect I’ll pre-declare mine anyway; it makes for nicer documentation and my build script can check to make sure I don’t declare a prop on an object that I didn’t individually declare, so I don’t fall prone to misspelling a custom property name.

1 Like

And thanks again, @Draconis !

I note that adding an individual property to an object that didn’t have any individual properties before, and assigning it a single value, costs 12 bytes. It doesn’t matter if the new property is declared or used in any other objects, so there’s apparently no cost of creating an individual property, except for the cost of actually using it in objects.

Adding another individual property to an object that already has one, costs 4 bytes.

2 Likes