LIsts of Object based Rulebooks don't seem to work.

I’m trying to play with lists of K based rulebooks but I the followinf doesn’t compile - it might not be allows but I really can event tell why
it’s not valid i7. It seems to work with plain rulebooks but not person based rulebooks…

I’ve added some some comments with the points about i7 syntax which don’t compile, and hope someone can explain what is happening in enough detail that if my approach is flawed I can find another

"rulebook lists" by "Allison Edwards"

The green room is a room.


The clump is a list of rulebooks that varies.


a thing has a list of rulebooks called the pile. 

[And why does this compile ! - there is nothing
 in the global scope called pile ?]
to push stuff (a new state - a  rulebook):
	add a new state to the pile ;
	


 [The next line compile without the 'that varies tag, but
the clump declaration didn't - why is there a difference, aren't
these two declarations the same in principle. It only the type in the
container which is different.
]
The stack is a list of person based rulebooks that varies.
a thing has a list of person based rulebooks called the heap.


[ This shows that you can add rulebooks to lists, and pass them as parameters ]
to slideup a (foo - a rulebook):
	add foo to the clump;



[The next to subroutines fail to compile and I really don't understand 
 why  - can someone help ?
The compile error is:

Problem. You wrote 'add a new state to the heap of the x' , which I tried to match against several possible phrase definitions. None of them worked.
1.  add (a new state - list of values) to (heap of the x - list of values) 
2.  add (a new state - value) to (heap of the x - list of values) 
I recognised:

a new state = a temporary named value, holding a people based rulebook
heap of the x = a property whose value is a lists of people based rulebook, holding a lists of people based rulebook
]

to pushstate (newstate - a person based rulebook):
	add newstate to the stack ;


to pushfoo (a new state - a person based rulebook) onto (x - a thing) :
	add a new state to the heap of the x;

It compiles if you drop “a person based rulebook” down to “a rulebook” everywhere. I don’t know if those are compatible. I would assume lists are polymorphic. Can you try inserting an instance of a ‘person based rulebook’ in the list? And accessing it?

I wonder if generic would work?
a K based rulebook
a K

[code][compiles with lists declared as “a rulebook”, but not as “a person based rulebook”.]
to pushstate (newstate - value of kind K based rulebook ):
add newstate to stack ;

to pushfoo (a new state - value of kind K based rulebook) onto (x - a thing) :
add a new state to the heap of x;[/code]

You can parameterise both sides (st=the stack). This compiles with lists declared as ‘person based rulebooks’.

[code]to pushstate (newstate - value of kind K based rulebook ) onto (st - list of value of kind L based rulebooks):
add newstate to st ;

to pushfoo (a new state - value of kind K based rulebook) onto (x - value of kind L) :
add a new state to the heap of x;[/code]

Instead of passing a thing, x, to pushfoo, why not pass ‘the heap of x’?

[code]The clump is a list of rulebooks that varies.

a thing has a list of rulebooks called the pile.

[And why does this compile ! - there is nothing
in the global scope called pile ?][/code]

You’ve created a new property that all things have, called ‘pile’. So now you can refer to “the pile of the chair” or “the pile of Susan”, each of which is a separate list. It’s not related at all to the “clump”, which is a single global variable.

Oh, I see. When you write

The stack is a list of person based rulebooks that varies.

…the compiler is generating a list-of-person based rulebook. Rather than a list of person-based-rulebooks.

You can construct the type you want with parentheses:

The stack is a list of (person based rulebooks) that varies.

Thanks zarf - that makes actual sense - I’d spotted the what heartless zombie said which is what really confused me - it didn;t look like there should have been a difference in the language treat the types differently - by the precedrence to the typedef being the other way explains it.

The reason I want to pass the person is not the rulebook is that in the full code there a number of related properties to keep ‘in step’. I’d use struct but Im not sure they exist in inform7.

Mike, I still don’t understand, when I say “add X to the pile” how does it know which thing’s pile to add X to ?

It doesn’t. It winds up using “the pile of the item described”, which might be the object you want or not, depending on where the phrase is called. You should specify a thing rather than relying on this.