Difference between revisions of "Peer-nodal.as"

From Organic Design wiki
(account for 0-length initial queue)
(Remove old comments)
Line 1: Line 1:
// NODAL ASSOCIATIONS
+
// ISSUES
 
// - associations (maintained class:instance relationships)
 
// - associations (maintained class:instance relationships)
//   instance.create/delete(class) calls class.create/delete(instance)
+
// - get should use class content as default - resolve() doesn't
//  create inserts the instance into the classes instance-loop (list-aspect, next/prev)
+
//  so either add get/set which use resolve, or remove object-freedom and have only .data
//  ie. our list of current children (that our E divides amongst) is also our instance-loop
 
//      has or is are one, they're all just relationships that receive a portion of energy
 
//  laster: a chain of delegate classes is created between root and the instance
 
// - the class of any assoc requires a portion of the quanta
 
//  remember, next/prev and complimented by parent/current (parent is also class)
 
// - this allows alternate quanta be divided between parent and current, thus providing
 
//  energy for the class->instance relationship
 
// - get retreives from class value if no instance value at each step of a path
 
 
 
// REDUCTION
 
// - all instance-loops work by going cd this.current then assigning this.current.next to it
 
//   when a function executes, it can update the loop at that location (equiv to array.push)
 
// - a functions parameters (and even further methods and tools) are child associations
 
//  the structures necessary to build the fucntion are child assocs too
 
 
 
// DATA STRUCTURE
 
// A question that keeps cropping up is:
 
//  is it best to use the language's native list type,
 
//  or to use a linked list constructed of ''next'' and ''prev'' refs.
 
// The best idea (since swf failed key-as-ref) is to use array-index-only as key,
 
// but allow any datatype as value, that way we can use a list or not later on
 
// values could be node-ref (index), list, lambda, or function-ref
 
 
 
// ==========================================================================================
 
  
 +
// NODAL PROPERTIES
 
// idcount is a accumulating-only counter for locally-unique-id number
 
// idcount is a accumulating-only counter for locally-unique-id number
 
// nodes is the current number of instantiated node objects
 
// nodes is the current number of instantiated node objects
Line 33: Line 10:
 
nodal = { queue: [], idcount: 0, nodes: 0 };
 
nodal = { queue: [], idcount: 0, nodes: 0 };
  
 +
// NODAL METHODS
 
// - the delete-list is only needed for limited list-space env
 
// - the delete-list is only needed for limited list-space env
 
// - Actionscript failed ref-as-hashkey test,
 
// - Actionscript failed ref-as-hashkey test,
Line 56: Line 34:
 
// Consume one quanta
 
// Consume one quanta
 
// - each quantum is actually two, one for local instance, one for global class
 
// - each quantum is actually two, one for local instance, one for global class
 +
// - all instance-loops work by going cd this.current then assigning this.current.next to it
 +
//  when a function executes, it can update the loop at that location (equiv to array.push)
 +
// - a functions parameters (and even further methods and tools) are child associations
 +
//  the structures necessary to build the fucntion are child assocs too
 
nodal.reduce = function( context ) {
 
nodal.reduce = function( context ) {
  

Revision as of 11:14, 6 April 2006

// ISSUES // - associations (maintained class:instance relationships) // - get should use class content as default - resolve() doesn't // so either add get/set which use resolve, or remove object-freedom and have only .data

// NODAL PROPERTIES // idcount is a accumulating-only counter for locally-unique-id number // nodes is the current number of instantiated node objects // queue is the root reduction queue nodal = { queue: [], idcount: 0, nodes: 0 };

// NODAL METHODS // - the delete-list is only needed for limited list-space env // - Actionscript failed ref-as-hashkey test, // so we use a id (locally unique identifier) as a lookup-key // - no delete currently // - just get/set properties with normal object-accessor way // - but keep all hierarchy nodal

// Resolve creates if non existent and returns reference to result nodal.resolve = function( context, path ) { while( path.length ) { var key = path.shift(); if ( context[key.id] == null ) { this.nodes++; var node = { queue: [], id: this.idcount++ }; context = context[key.id] = node; } else context = context[ key.id ]; } return context; };

// Consume one quanta // - each quantum is actually two, one for local instance, one for global class // - all instance-loops work by going cd this.current then assigning this.current.next to it // when a function executes, it can update the loop at that location (equiv to array.push) // - a functions parameters (and even further methods and tools) are child associations // the structures necessary to build the fucntion are child assocs too nodal.reduce = function( context ) {

if ( node = context.queue.pop() ) {

// is there a local declaration? // - if yes, execute it and also reduce( class ) // - if no, { reduce( node ) if it has a queue, back to root if not }

}

// Old ECMA SIC reduction for ( var i = 1; i == 1; ) { var queue = cwd.queue; if ( queue.length > 0 ) { var todo = queue.shift(); if ( next = typeOf( todo ) == 'function' ? ( i = todo.call ) : ( cwd = todo ) ) queue.push( next ); } else i = 0; } };