jbee / panda

A early draft for a template rendering notation defined inside the template itself.
1 stars 0 forks source link

Override variables so that they aren't rebound any more #10

Open jbee opened 13 years ago

jbee commented 13 years ago

When a Var is overridden, the new definition is prepanded. In addition there has to be a search starting a zero/one for the first definition of the same variable. This has to be marked as overridden so that it will not be bound any more. The context should keep track of the last BehaviouralFunctor that is not overridden to reduce lookup costs.

jbee commented 13 years ago

The rebind and bind can be rewritten so that newly defined variables during the bind will be bind also. Therefore we can do a loop starting at the last index of the definitions list. The loop is done when index 0 has been bound. As counter we count the amount of already bound definitions (counting from the end of the list). This will always increment by 1 in a loop. The index to bind/rebind next is list.length() - bound - 1.

We can pass a int parameter rebinds that is the amount of rebinds done before bind is used. Through that we can use the same loop/method for both: bind and rebind.