we are working on a computer graphics and debugging system that involves capturing moments in time when certain properties occurred on sets of objects
The A will capture moments of time that sets of C had properties that occurred. The A will talk of C. The A.c.ip always positions A amongst a pile of A(.y.up=Aabove or .sc.z=[Abelow]) with various properties to recurse into, each coming from some other A.
you should be able to build a robust and reliable system.
A has four properties: t, y, c, sc. so does C. A.t is the name of a kind of object class to apply to the A. A.t is looked up in the mind, finding a thing to be like. y contains properties with the most empiricism from the underlying machine in them, eg A.y.up links to the A this A was sprouted from, A.y.cv is a fraction of 1 where the A is, etc. c contains properties still of quite machiney disposition, eg A.c.pi (unrelated to Math.pi or A.c.ip) is a super- and sub-type of class to apply (ie act like a pi of spacal if {pi:'spacal'}) forming the base identity of most atoms in most situations in the program, except perhaps in highly specialised corners. A.sc is the most open to the universal qualities of the thing in itself, beyond the machine that holds it, eg A.sc.colour is a pure essence from the thing we are modelling (on the machine)
const i = (C, z) => {
if (!C.sc) C.sc = {};
if (!C.sc[z]) C.sc[z] = [];
C.sc[z].push(C);
};
lets make typescript for A and C forming. the A class should let us A.A_(...). A should extend C. the C_(t,y,c,sc) function that makes a C from a list, and we use inside A.A_(t,y,c,sc) to make new A (with subdividing|serial-numbered A.c.ip). C dont usually have an ip, but A always do. C_('Bev') should return an empty C except for C.t='Bev' with the C.y|c|sc empty hashes|objects.
use A1 = C_('toplevel') to make the first A (whose A.c.ip = 1),
use A11 = A1.A_('someprocess') to create A:1.1 (A11.c.ip=[1,1]), begins serial A1.c.ips=1 (number of children had), does i_(A1, A11) to add A:1.1 to A:1 (into A1.sc.z=[...])
then give all A:1.* some C, with i_(). i_() must C.sc.z ||= [] to hold C, or C.sc.etc if qua='etc'. C.sc.z tends to mean "inside of". by default A have their children in A.sc.z, but they might move out...
if given no t argument in C_() or A_(), C.t can be set to '', A.t usu inherit from above.
the y,c,sc are each empty objects until properties are defined (eg C.sc.z), and all C should be created by C_() (and A by A.A_(), except the toplevel that is made by C_() and mutated into an A as above)
you shouldn't have to specify any y|c|sc in C_ or A_ you dont want to. C.t may be ''. C.c.ip generally dont happen whereas A.c.ip always does, just as C may not be in anything but A always are. all the A.c.ip looks good, but the counter needs to be on the A itself (not as static) and appear only when the A becomes a parent. A.c.ip should really be an array of numbers, so we can sort it well.
export function realisme () {let A1 = C_('toplevel')A1.c.ip = [1]let A11 = A_(A,'glamphor')// create some Cs for authorslet Joyce = C_('Joyce', {}, {born: '1882', died: '1941'}, {author: true})let Faulkner = C_('Faulkner', {}, {born: '1897', died: '1962'}, {author: true})let Woolf = C_('Woolf', {}, {born: '1882', died: '1941'}, {author: true})// create some As with authorslet A1 = A_(C_('toplevel', {}, {}, {author: false}))let A11 = A_(A1, 'glamphor')i_(A1, A11)let A111 = A_(A11, 'Dublin')C_(A111, {}, {author: Joyce})return [A1, A11]}// the baskets of properties that are C.y|c|scinterface gc {[key: string]: any}interface C {t: string; // name of object class to apply to Cy: gc; // properties derived from the underlying machinec: gc; // properties defining the base identity of Csc: gc; // properties representing the essential qualities of C}interface A extends C {y: {up?: A; // A this A was sprouted from}c: {ip: number[]; // IP address of variable lengthips?: number; // how many children it has had}}// make new C, specifying innardsfunction C_(t: string|Array|C, y?:number|gc, c?:gc, sc?:gc):C {if (isar(t)) {[t,y,c,sc] = t}if (!isst(t)) {// t must be C, from C_(C)throw "TODO clone = C_(C)"}if (isnum(y)) {if (y <= 0)throw "y <= 0"while (y > 1)y /= 10y = {cv:y}}t ||= ''y ||= {}c ||= {}sc ||= {}return {t,y,c,sc}}function A_(A:A, t?:string):A {t ||= A.tlet A2 = C_(t)// ip address (infinite position)A.c.ips ||= 0A.c.ips++A2.c.ip = [...A.c.ip,A.c.ips]// parentA2.y.up = Ai_(A,A2)return A2}function i_(C1: C, C2: C, qua: string = 'z') {let N = C1.sc[qua] ||= []N.push(C2)}// type checking, ported from Fividyfunction isst(s) {return typeof s == 'string'}function isnu(s) {return typeof s == 'number'}function isnum(s) {return (isnu(s) || s && s.length && !isspace(s)) && s*1 == s}function isar(s) {return s && s.constructor == Array}let spacechars = {" ":1,"\n":1,"\t":1}function isspace(s) {return hak(s) && !havs(s).some(s => !spacechars[s])}// and further backfunction hak(s,d) {if (!s)return 0return d == null ? Object.keys(s).length : s.hasOwnProperty(d)}function havs(s,d) {return haks(s).map(k => s [k])}function haks(s,d) {let N = [];if (!s) {return N}for (let k in s) {let v = s[k]if (d == 'kv') { N.push(k,v) }elseif (d == 's') { N.push(v) }else {N.push(k);}}return N}
No comments:
Post a Comment