# HG changeset patch # User Ian Goodfellow # Date 1285164348 14400 # Node ID 33513a46c41bcf6b2bc17c6c284dcf0421a73d54 # Parent 478bb1f8215cdbd79456f416b4081425cec53377 added comments on plugin_JB diff -r 478bb1f8215c -r 33513a46c41b doc/v2_planning/arch_src/plugin_JB_comments_IG.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/v2_planning/arch_src/plugin_JB_comments_IG.txt Wed Sep 22 10:05:48 2010 -0400 @@ -0,0 +1,61 @@ +-Does everything have to be all caps? I know I will get annoyed with that. +-Regarding overall program structure: + Do you think there might be an easier to read/type way of specifying programs than building them out of constructors? This seems like it's going to lead to unwieldy proliferation of parentheses, like in LISP, but since it's an imperative language it's more likely that we'll have lots of different scopes visible at the same time, and it will be hard to tell which section is nested inside which other section if they're all just a bunch of constructor calls fed to each other. + Right now it just seems to take a few layers of SWITCH and SEQ to end up with an unreadable mess: +I know I'm not getting the syntax exactly matched to you proposal, but just to illustrate what I'm saying, we could have a program that looks like this: +program = SEQ( A, B, SWITCH(var1, val1_1, C, val_1_2, SWITCH(var2, val_2_1, D, val_2_2, E) ) , F, SWITCH(var3, val_3_1, G, val_3_2, H) ) +This seems like it could quickly turn into a nightmare, trying to count parentheses everywhere. An alternative to make it more parseable is: + +switch1 = SWITCH(var2, val_2_1, D, val_2_2, E) +switch2 = SWITCH(var1, val1_1, C, val_1_2, switch1) +switch3 = SWITCH(var3, val_3_1, G, val_3_2, H) +program = SEQ( A, B, switch2 , F, switch3) + +This is a lot more manageable but now the parts are out of order, so the cognitive load required to debug and understand it doesn't scale well with program size. + +It would be much nicer if, since it is a programming language, we could write: + +A +B +SWITCH var1 + val1, C + val_1_2, SWITCH var2 + val_2_1, D + val_2_2, E + F + SWITCH var3 + val_3_1, G + val_3_2, H + +I can see a few different ways of accomplishing this, but of couse welcome more proposals: + +1) Make a scripting language, so we pass a file into our library. We could base it on XML, maybe, if we didn't want to spend too much time making our own parser: + +switch.xml contains: + + + + + + + + ... + + + +python pylearn.py switch.xml + +2) We could make a global program compiler or have program objects that have an idea of the current scope, that you just add things to: + +p = pylearn.program() +p(A) +p(B) +p(SWITCH(var1)) +p( Branch(val_1_1, C)) #one annoying thing is python wouldn't let us indent things as we please +... +p(END_SWITCH) +... +p.compile() +p.run() + +If we design our language to be LL(1) (fairly easy to do) then it's pretty easy to make p check that the calls to it are syntactically correct as they happen.