The DM4, which doesn’t really touch on Glulx, says that the limit on the elements that a property array may contain is 32. That number is for Z5/Z8–I assume that Glulx Inform does away with the limitation, but can anyone confirm this?
Also, @malloc and @linearsearch–I’m probably not smart enough to figure out how to use these anyway, but does @malloc allow for dynamically changing the size of a property array? And I assume @linearsearch will accelerate seeking through one, but is that correct?
In Glulx the hard limit is 32768 entries. You will have to increase MAX_OBJ_PROP_TABLE_SIZE and MAX_PROP_TABLE_SIZE before you reach that point.
Not directly. The property array is part of the object property table, which is a fixed-size data table in RAM. However, its format is documented, so building a new one in allocated memory isn’t hard. I believe one of vaporware’s extensions does this.
A couple more questions, I’m afraid. Property arrays are pretty poorly covered in the DM4, but together with the DM4 and Doe’s I6 pages, it seems that the only way to define a property array is by spelling it out entry for entry, e.g.:
…because that would be a whole lot nicer. To clarify: I’ve tried the latter syntax, and received compiler errors–but perhaps there’s an alternate way to do it?
Also, in the absence of the arrow syntax, how does Inform know whether I’m creating a byte array or a word array? Does it simply infer based on the values given when the property array is declared?
Thanks for the clarification. I’m casting around for the lightest data structures I can use for storing quite a bit of information, but for a variety of reasons (for which this is just the topper), it looks like, for most cases at least, only I7 lists are going to be comfortable to use.
The DM4 has this at the end of §3.5: “people fairly often use property arrays as byte arrays to save on memory”, which seemed to indicate that there was some way to create a byte property array. But since there is in fact no way to specify the type explicitly, it makes more sense that it would also be a word array.
I don’t know if that ever was common, really. But what that means is simply (say) defining “prop 0 0 0 0” and then using the four words as eight bytes. Since obj.&prop gives you the beginning of the array, and it’s contiguous, you can use it as whatever.