Difference between revisions of "Peer-nodal.as"
(begin with fake list-space made of array) |
(create nodal object) |
||
Line 30: | Line 30: | ||
// - create and delete are called internally from get/set | // - create and delete are called internally from get/set | ||
− | function | + | nodal = {}; |
− | return free.pop(); | + | nodal.root = []; |
− | } | + | nodal.free = []; |
+ | |||
+ | nodal.create = function() { | ||
+ | return this.free.pop(); | ||
+ | }; | ||
− | function | + | nodal.delete = function( node ) { |
free.push( node ); | free.push( node ); | ||
− | } | + | }; |
− | |||
// Actionscript failed ref-as-hashkey test | // Actionscript failed ref-as-hashkey test | ||
Line 45: | Line 48: | ||
// - using "list" and "object" children in every node | // - using "list" and "object" children in every node | ||
// - prefixes 'i' before lookups to ensure its treated as a key not an index | // - prefixes 'i' before lookups to ensure its treated as a key not an index | ||
− | function | + | nodal.traverse = function( path ) { |
ptr = this; | ptr = this; | ||
for ( i in path ) ptr = ptr['i'+i]; | for ( i in path ) ptr = ptr['i'+i]; | ||
Line 51: | Line 54: | ||
} | } | ||
− | function | + | nodal.store = function( key, val ) { |
this['i'+key] = val; | this['i'+key] = val; | ||
} | } | ||
− | function | + | nodal.fetch = function( key ) { |
return this['i'+key]; | return this['i'+key]; | ||
} | } | ||
Line 61: | Line 64: | ||
// This is the old ecma reduction tree taken from SIC code | // This is the old ecma reduction tree taken from SIC code | ||
// - needs major modification, but has the core language features needed | // - needs major modification, but has the core language features needed | ||
− | function | + | nodal.reduce = function() { |
cwd = root; | cwd = root; | ||
for (var i = 1; i == 1;) { | for (var i = 1; i == 1;) { |
Revision as of 07:14, 6 April 2006
// NODAL ASSOCIATIONS // - associations (maintained class:instance relationships) // instance.create/delete(class) calls class.create/delete(instance) // create inserts the instance into the classes instance-loop (list-aspect, next/prev) // 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
// We'll fake a list-space with an array
// - create and delete are called internally from get/set
nodal = {}; nodal.root = []; nodal.free = [];
nodal.create = function() { return this.free.pop(); };
nodal.delete = function( node ) { free.push( node ); };
// Actionscript failed ref-as-hashkey test // - so we need to make a traverse(class-path-list) method to replace hash-accessor-syntax // - Note to Jack & Rob: this is not list-space-traversal, // each item in this class-path-list would require a list-space-traversal call // - using "list" and "object" children in every node // - prefixes 'i' before lookups to ensure its treated as a key not an index nodal.traverse = function( path ) { ptr = this; for ( i in path ) ptr = ptr['i'+i]; return ptr; }
nodal.store = function( key, val ) { this['i'+key] = val; }
nodal.fetch = function( key ) { return this['i'+key]; }
// This is the old ecma reduction tree taken from SIC code // - needs major modification, but has the core language features needed nodal.reduce = function() { cwd = root; 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; } }