Tuesday, August 2, 2016

jse note 1

function createfunction(parent) {
nameit()
linkit()
codeit()}

function editfunction(function) {}

function addrootfunction() {}

what does the program string look like?

let's say we start by creating a variable

var string = 'var v = ""'

then we add a function

var string = 'var v = ""<level 0>function f(param) {'

now we'll add a variable and a function in f

var string = 'var v = ""<level 0>function f(param) {var v = ""<level 1>function ff(param) {'

OK, let's look at what it would take to parse this string.

var level_0 = string.split('<level 0>')

now, let's say we want to look at function f

let's also be clear that what we want to see is
1) yes, the function name and parameter list
2) yes, the variables declared in the function
3) function calls in the function
4) function declarations in the function
but not
5) any statements in functions called in the function

woops, that's not correct!

what we want to see is:
1) yes, the function name and parameter list
2) yes, the variables declared in the function
3) function calls in the function
but not4) function declarations in the function
5) any statements in functions called in the function

we are reading the program code, but we don't want some endless scroll of code, what we want is to see a very few compact statement, at any one time

function root() {
call_1()
call_2()
call_3()}

each of the calls calls a function, which might contain many, many lines of code, but we don't want to see all those lines of code. seeing all those lines of code would be completely impractical. the three calls show us, in a neatly compact way, everything in the root function.

now, if we want to look into what's in one of the called functions, in our editor we would click the function call. the result would be something like:

function call_1() { //path = root/
call_1_1()
call_1_2()
call_1_3()}

This is a little unrealistic, an abstract illustration, but maybe you can see how we're working our way into a tree with many branches, while always looking at a very rational listing of statements.