Difference between revisions of "Peer-nodal.as"

From Organic Design wiki
 
(Add data-structure plan)
Line 1: Line 1:
 +
// 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
 +
 +
 +
 +
 
// Actionscript failed ref-as-hashkey test
 
// Actionscript failed ref-as-hashkey test
 
// - so we need to make a traverse(class-path-list) method to replace hash-accessor-syntax
 
// - so we need to make a traverse(class-path-list) method to replace hash-accessor-syntax

Revision as of 06:49, 28 March 2006

// 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



// 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 function traverse( path ) { ptr = this; for ( i in path ) ptr = ptr['i'+i]; return ptr; }

function store( key, val ) { this['i'+key] = val; }

function fetch( 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 function reduce() { 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; } }