annotate doc/v2_planning/arch_src/plugin_JB_comments_IG.txt @ 1213:33513a46c41b

added comments on plugin_JB
author Ian Goodfellow
date Wed, 22 Sep 2010 10:05:48 -0400
parents
children 4754661ad6ab
rev   line source
1213
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
1 -Does everything have to be all caps? I know I will get annoyed with that.
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
2 -Regarding overall program structure:
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
3 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.
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
4 Right now it just seems to take a few layers of SWITCH and SEQ to end up with an unreadable mess:
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
5 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:
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
6 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) )
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
7 This seems like it could quickly turn into a nightmare, trying to count parentheses everywhere. An alternative to make it more parseable is:
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
8
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
9 switch1 = SWITCH(var2, val_2_1, D, val_2_2, E)
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
10 switch2 = SWITCH(var1, val1_1, C, val_1_2, switch1)
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
11 switch3 = SWITCH(var3, val_3_1, G, val_3_2, H)
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
12 program = SEQ( A, B, switch2 , F, switch3)
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
13
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
14 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.
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
15
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
16 It would be much nicer if, since it is a programming language, we could write:
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
17
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
18 A
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
19 B
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
20 SWITCH var1
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
21 val1, C
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
22 val_1_2, SWITCH var2
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
23 val_2_1, D
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
24 val_2_2, E
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
25 F
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
26 SWITCH var3
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
27 val_3_1, G
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
28 val_3_2, H
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
29
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
30 I can see a few different ways of accomplishing this, but of couse welcome more proposals:
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
31
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
32 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:
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
33
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
34 switch.xml contains:
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
35 <PyLearn>
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
36 <A />
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
37 <B />
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
38 <Switch var="var_1">
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
39 <Branch val="val_1_1">
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
40 <C>
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
41 </Branch>
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
42 ...
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
43 </Switch>
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
44 </Pylearn>
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
45
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
46 python pylearn.py switch.xml
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
47
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
48 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:
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
49
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
50 p = pylearn.program()
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
51 p(A)
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
52 p(B)
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
53 p(SWITCH(var1))
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
54 p( Branch(val_1_1, C)) #one annoying thing is python wouldn't let us indent things as we please
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
55 ...
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
56 p(END_SWITCH)
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
57 ...
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
58 p.compile()
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
59 p.run()
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
60
33513a46c41b added comments on plugin_JB
Ian Goodfellow
parents:
diff changeset
61 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.