shen-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. data/.gitignore +4 -0
  2. data/.rspec +0 -0
  3. data/Gemfile +6 -0
  4. data/Gemfile.lock +20 -0
  5. data/MIT_LICENSE.txt +26 -0
  6. data/README.md +94 -0
  7. data/bin/shen_test_suite.rb +9 -0
  8. data/bin/srrepl +23 -0
  9. data/lib/kl.rb +7 -0
  10. data/lib/kl/absvector.rb +12 -0
  11. data/lib/kl/compiler.rb +253 -0
  12. data/lib/kl/cons.rb +51 -0
  13. data/lib/kl/empty_list.rb +12 -0
  14. data/lib/kl/environment.rb +123 -0
  15. data/lib/kl/error.rb +4 -0
  16. data/lib/kl/internal_error.rb +7 -0
  17. data/lib/kl/lexer.rb +186 -0
  18. data/lib/kl/primitives/arithmetic.rb +60 -0
  19. data/lib/kl/primitives/assignments.rb +18 -0
  20. data/lib/kl/primitives/booleans.rb +17 -0
  21. data/lib/kl/primitives/error_handling.rb +13 -0
  22. data/lib/kl/primitives/generic_functions.rb +22 -0
  23. data/lib/kl/primitives/lists.rb +21 -0
  24. data/lib/kl/primitives/streams.rb +38 -0
  25. data/lib/kl/primitives/strings.rb +55 -0
  26. data/lib/kl/primitives/symbols.rb +17 -0
  27. data/lib/kl/primitives/time.rb +17 -0
  28. data/lib/kl/primitives/vectors.rb +30 -0
  29. data/lib/kl/reader.rb +40 -0
  30. data/lib/kl/trampoline.rb +14 -0
  31. data/lib/shen_ruby.rb +7 -0
  32. data/lib/shen_ruby/version.rb +3 -0
  33. data/shen-ruby.gemspec +26 -0
  34. data/shen/README.txt +17 -0
  35. data/shen/lib/shen_ruby/shen.rb +124 -0
  36. data/shen/license.txt +34 -0
  37. data/shen/release/benchmarks/N_queens.shen +45 -0
  38. data/shen/release/benchmarks/README.shen +14 -0
  39. data/shen/release/benchmarks/benchmarks.shen +56 -0
  40. data/shen/release/benchmarks/bigprog +2173 -0
  41. data/shen/release/benchmarks/br.shen +13 -0
  42. data/shen/release/benchmarks/einstein.shen +33 -0
  43. data/shen/release/benchmarks/heatwave.gif +0 -0
  44. data/shen/release/benchmarks/interpreter.shen +219 -0
  45. data/shen/release/benchmarks/picture.jpg +0 -0
  46. data/shen/release/benchmarks/plato.jpg +0 -0
  47. data/shen/release/benchmarks/powerset.shen +10 -0
  48. data/shen/release/benchmarks/prime.shen +10 -0
  49. data/shen/release/benchmarks/short.shen +129 -0
  50. data/shen/release/benchmarks/text.txt +68 -0
  51. data/shen/release/k_lambda/core.kl +1002 -0
  52. data/shen/release/k_lambda/declarations.kl +1021 -0
  53. data/shen/release/k_lambda/load.kl +94 -0
  54. data/shen/release/k_lambda/macros.kl +479 -0
  55. data/shen/release/k_lambda/prolog.kl +1309 -0
  56. data/shen/release/k_lambda/reader.kl +1058 -0
  57. data/shen/release/k_lambda/sequent.kl +556 -0
  58. data/shen/release/k_lambda/sys.kl +582 -0
  59. data/shen/release/k_lambda/t-star.kl +3493 -0
  60. data/shen/release/k_lambda/toplevel.kl +223 -0
  61. data/shen/release/k_lambda/track.kl +208 -0
  62. data/shen/release/k_lambda/types.kl +455 -0
  63. data/shen/release/k_lambda/writer.kl +108 -0
  64. data/shen/release/k_lambda/yacc.kl +280 -0
  65. data/shen/release/test_programs/Chap13/problems.txt +26 -0
  66. data/shen/release/test_programs/README.shen +53 -0
  67. data/shen/release/test_programs/TinyLispFunctions.txt +16 -0
  68. data/shen/release/test_programs/TinyTypes.shen +55 -0
  69. data/shen/release/test_programs/binary.shen +24 -0
  70. data/shen/release/test_programs/bubble_version_1.shen +28 -0
  71. data/shen/release/test_programs/bubble_version_2.shen +22 -0
  72. data/shen/release/test_programs/calculator.shen +21 -0
  73. data/shen/release/test_programs/cartprod.shen +23 -0
  74. data/shen/release/test_programs/change.shen +25 -0
  75. data/shen/release/test_programs/classes-defaults.shen +94 -0
  76. data/shen/release/test_programs/classes-inheritance.shen +100 -0
  77. data/shen/release/test_programs/classes-typed.shen +74 -0
  78. data/shen/release/test_programs/classes-untyped.shen +46 -0
  79. data/shen/release/test_programs/depth_.shen +14 -0
  80. data/shen/release/test_programs/einstein.shen +33 -0
  81. data/shen/release/test_programs/fruit_machine.shen +46 -0
  82. data/shen/release/test_programs/interpreter.shen +219 -0
  83. data/shen/release/test_programs/metaprog.shen +85 -0
  84. data/shen/release/test_programs/minim.shen +193 -0
  85. data/shen/release/test_programs/mutual.shen +11 -0
  86. data/shen/release/test_programs/n_queens.shen +45 -0
  87. data/shen/release/test_programs/newton_version_1.shen +33 -0
  88. data/shen/release/test_programs/newton_version_2.shen +24 -0
  89. data/shen/release/test_programs/parse.prl +14 -0
  90. data/shen/release/test_programs/parser.shen +52 -0
  91. data/shen/release/test_programs/powerset.shen +10 -0
  92. data/shen/release/test_programs/prime.shen +10 -0
  93. data/shen/release/test_programs/proof_assistant.shen +81 -0
  94. data/shen/release/test_programs/proplog_version_1.shen +25 -0
  95. data/shen/release/test_programs/proplog_version_2.shen +27 -0
  96. data/shen/release/test_programs/qmachine.shen +67 -0
  97. data/shen/release/test_programs/red-black.shen +55 -0
  98. data/shen/release/test_programs/search.shen +56 -0
  99. data/shen/release/test_programs/semantic_net.shen +44 -0
  100. data/shen/release/test_programs/spreadsheet.shen +35 -0
  101. data/shen/release/test_programs/stack.shen +27 -0
  102. data/shen/release/test_programs/streams.shen +20 -0
  103. data/shen/release/test_programs/strings.shen +59 -0
  104. data/shen/release/test_programs/structures-typed.shen +71 -0
  105. data/shen/release/test_programs/structures-untyped.shen +42 -0
  106. data/shen/release/test_programs/tests.shen +294 -0
  107. data/shen/release/test_programs/types.shen +11 -0
  108. data/shen/release/test_programs/whist.shen +240 -0
  109. data/shen/release/test_programs/yacc.shen +136 -0
  110. data/spec/kl/cons_spec.rb +12 -0
  111. data/spec/kl/environment_spec.rb +306 -0
  112. data/spec/kl/lexer_spec.rb +149 -0
  113. data/spec/kl/primitives/generic_functions_spec.rb +29 -0
  114. data/spec/kl/primitives/symbols_spec.rb +21 -0
  115. data/spec/kl/reader_spec.rb +36 -0
  116. data/spec/spec_helper.rb +2 -0
  117. metadata +189 -0
@@ -0,0 +1,13 @@
1
+ (defcc <br>
2
+ 40 <br> 41 <br$> := ok;
3
+ <item> <br> := ok;
4
+ <e> := ok;)
5
+
6
+ (defcc <br$>
7
+ <br> := ok;)
8
+
9
+ (defcc <item>
10
+ -*- := (if (element? -*- [40 41])
11
+ (fail)
12
+ ok);)
13
+
@@ -0,0 +1,33 @@
1
+ (defprolog einsteins_riddle
2
+ Fish_Owner <-- (einstein Houses Fish_Owner);)
3
+
4
+ (defprolog einstein
5
+ Houses Fish_Owner <-- (unify Houses [[house norwegian _ _ _ _] _ [house _ _ _ milk _] _ _])
6
+ (member [house brit _ _ _ red] Houses)
7
+ (member [house swede dog _ _ _] Houses)
8
+ (member [house dane _ _ tea _] Houses)
9
+ (iright [house _ _ _ _ green] [house _ _ _ _ white] Houses)
10
+ (member [house _ _ _ coffee green] Houses)
11
+ (member [house _ bird pallmall _ _] Houses)
12
+ (member [house _ _ dunhill _ yellow] Houses)
13
+ (next_to [house _ _ dunhill _ _] [house _ horse _ _ _] Houses)
14
+ (member [house _ _ _ milk _] Houses)
15
+ (next_to [house _ _ marlboro _ _] [house _ cat _ _ _] Houses)
16
+ (next_to [house _ _ marlboro _ _] [house _ _ _ water _] Houses)
17
+ (member [house _ _ winfield beer _] Houses)
18
+ (member [house german _ rothmans _ _] Houses)
19
+ (next_to [house norwegian _ _ _ _] [house _ _ _ _ blue] Houses)
20
+ (unify Houses [[house norwegian _ _ _ _] _ [house _ _ _ milk _] _ _])
21
+ (member [house Fish_Owner fish _ _ _] Houses);)
22
+
23
+ (defprolog member
24
+ X [X | _] <--;
25
+ X [_ | Z] <-- (member X Z);)
26
+
27
+ (defprolog next_to
28
+ X Y List <-- (iright X Y List);
29
+ X Y List <-- (iright Y X List);)
30
+
31
+ (defprolog iright
32
+ L R [L | [R | _]] <--;
33
+ L R [_ | Rest] <-- (iright L R Rest);)
@@ -0,0 +1,219 @@
1
+ (datatype num
2
+
3
+ ____________________________________
4
+ (number? X) : verified >> X : number;)
5
+
6
+ (datatype primitive_object
7
+
8
+ if (variable? X)
9
+ _______________
10
+ X : variable;
11
+
12
+ X : variable;
13
+ _____________
14
+ X : primitive_object;
15
+
16
+ X : symbol;
17
+ ___________
18
+ X : primitive_object;
19
+
20
+ X : string;
21
+ ___________
22
+ X : primitive_object;
23
+
24
+ X : boolean;
25
+ ___________
26
+ X : primitive_object;
27
+
28
+ X : number;
29
+ ___________
30
+ X : primitive_object;
31
+
32
+ _____________________
33
+ [] : primitive_object;)
34
+
35
+ (datatype pattern
36
+
37
+ X : primitive_object;
38
+ ___________
39
+ X : pattern;
40
+
41
+ P1 : pattern; P2 : pattern;
42
+ ===========================
43
+ [cons P1 P2] : pattern;
44
+
45
+ P1 : pattern; P2 : pattern;
46
+ ===========================
47
+ [@p P1 P2] : pattern;)
48
+
49
+ (datatype l_formula
50
+
51
+ X : pattern;
52
+ _____________
53
+ X : l_formula;
54
+
55
+ X : l_formula; Y : l_formula; Z : l_formula;
56
+ =================================
57
+ [if X Y Z] : l_formula;
58
+
59
+ X : variable; Y : l_formula; Z : l_formula;
60
+ ================================
61
+ [let X Y Z] : l_formula;
62
+
63
+ X : l_formula; Y : l_formula;
64
+ ======================
65
+ [cons X Y] : l_formula;
66
+
67
+ X : l_formula; Y : l_formula;
68
+ ======================
69
+ [@p X Y] : l_formula;
70
+
71
+ X : l_formula; Y : l_formula;
72
+ ======================
73
+ [where X Y] : l_formula;
74
+
75
+ X : l_formula; Y : l_formula;
76
+ ======================
77
+ [= X Y] : l_formula;
78
+
79
+ X : l_formula; Y : l_formula;
80
+ ======================
81
+ [X Y] : l_formula;
82
+
83
+ Xn : (list l_formula);
84
+ ===================
85
+ [cases | Xn] : l_formula;
86
+
87
+ P : pattern; X : l_formula;
88
+ ===========================
89
+ [/. P X] : l_formula;)
90
+
91
+ (define l_interpreter
92
+ {A --> B}
93
+ _ -> (read_eval_print_loop (output "~%L interpreter ~%~%~%~%l-interp --> ~A~%"
94
+ (normal_form (input+ : l_formula)))))
95
+
96
+ (define read_eval_print_loop
97
+ {string --> A}
98
+ _ -> (read_eval_print_loop
99
+ (output "l-interp --> ~A~%"
100
+ (normal_form (input+ : l_formula)))))
101
+
102
+ (define normal_form
103
+ {l_formula --> l_formula}
104
+ X -> (fix ==> X))
105
+
106
+ (define ==>
107
+ {l_formula --> l_formula}
108
+ [= X Y] -> (let X* (normal_form X)
109
+ (let Y* (normal_form Y)
110
+ (if (or (eval_error? X*) (eval_error? Y*))
111
+ "error!"
112
+ (if (= X* Y*) true false))))
113
+ [[/. P X] Y] -> (let Match (match P (normal_form Y))
114
+ (if (no_match? Match)
115
+ "no match"
116
+ (sub Match X)))
117
+ [if X Y Z] -> (let X* (normal_form X)
118
+ (if (= X* true)
119
+ Y
120
+ (if (= X* false)
121
+ Z
122
+ "error!")))
123
+ [let X Y Z] -> [[/. X Z] Y]
124
+ [@p X Y] -> (let X* (normal_form X)
125
+ (let Y* (normal_form Y)
126
+ (if (or (eval_error? X*) (eval_error? Y*))
127
+ "error!"
128
+ [@p X* Y*])))
129
+ [cons X Y] -> (let X* (normal_form X)
130
+ (let Y* (normal_form Y)
131
+ (if (or (eval_error? X*) (eval_error? Y*))
132
+ "error!"
133
+ [cons X* Y*])))
134
+ [++ X] -> (successor (normal_form X))
135
+ [-- X] -> (predecessor (normal_form X))
136
+ \*[cases X1 | Xn] -> (let Case1 (normal_form X1)
137
+ (if (= Case1 "no match")
138
+ [cases | Xn]
139
+ Case1))
140
+ [cases] -> "error!"
141
+ [where X Y] -> [if X Y "no match"]
142
+ [y-combinator [/. X Y]] -> (replace X [y-combinator [/. X Y]] Y)
143
+ [X Y] -> (let X* (normal_form X)
144
+ (let Y* (normal_form Y)
145
+ (if (or (eval_error? X*) (eval_error? Y*))
146
+ "error!"
147
+ [X* Y*])))*\
148
+ X -> X)
149
+
150
+ (define eval_error?
151
+ {l_formula --> boolean}
152
+ "error!" -> true
153
+ "no match" -> true
154
+ _ -> false)
155
+
156
+ (define successor
157
+ {A --> l_formula}
158
+ X -> (+ 1 X) where (number? X)
159
+ _ -> "error!")
160
+
161
+ (define predecessor
162
+ {A --> l_formula}
163
+ X -> (- X 1) where (number? X)
164
+ _ -> "error!")
165
+
166
+ \* (spy +) *\
167
+
168
+ (define sub
169
+ {[(pattern * l_formula)] --> l_formula --> l_formula}
170
+ [] X -> X
171
+ [(@p Var Val) | Assoc] X -> (sub Assoc (replace Var Val X)))
172
+
173
+ (define match
174
+ {pattern --> l_formula --> (list (pattern * l_formula))}
175
+ P X -> [] where (== P X)
176
+ P X -> [(@p P X)] where (variable? P)
177
+ [cons P1 P2] [cons X Y] -> (let Match1 (match P1 X)
178
+ (if (no_match? Match1)
179
+ Match1
180
+ (let Match2 (match P2 Y)
181
+ (if (no_match? Match2)
182
+ Match2
183
+ (append Match1 Match2)))))
184
+ [@p P1 P2] [@p X Y] -> (let Match1 (match P1 X)
185
+ (if (no_match? Match1)
186
+ Match1
187
+ (let Match2 (match P2 Y)
188
+ (if (no_match? Match2)
189
+ Match2
190
+ (append Match1 Match2)))))
191
+
192
+ _ _ -> [(@p no matching)])
193
+
194
+ (define no_match?
195
+ {[(pattern * l_formula)] --> boolean}
196
+ [(@p no matching)] -> true
197
+ _ -> false)
198
+
199
+ (define replace
200
+ {pattern --> l_formula --> l_formula --> l_formula}
201
+ V W [let V* X Y] -> [let V* X Y] where (== V V*)
202
+ X Y X -> Y
203
+ V W [= X Y] -> [= (replace V W X) (replace V W Y)]
204
+ V W [/. P X] -> [/. P (replace V W X)] where (free? V P)
205
+ V W [if X Y Z] -> [if (replace V W X) (replace V W Y) (replace V W Z)]
206
+ V W [let X Y Z] -> [let X (replace V W Y) (replace V W Z)]
207
+ V W [@p X Y] -> [@p (replace V W X) (replace V W Y)]
208
+ V W [cons X Y] -> [cons (replace V W X) (replace V W Y)]
209
+ V W [cases | Xn] -> [cases | (map (/. Xi (replace V W Xi)) Xn)]
210
+ V W [where X Y] -> [where (replace V W X) (replace V W Y)]
211
+ V W [X Y] -> [(replace V W X) (replace V W Y)]
212
+ _ _ X -> X)
213
+
214
+ (define free?
215
+ {pattern --> pattern --> boolean}
216
+ P P -> false
217
+ P [cons P1 P2] -> (and (free? P P1) (free? P P2))
218
+ P [@p P1 P2] -> (and (free? P P1) (free? P P2))
219
+ _ _ -> true)
Binary file
Binary file
@@ -0,0 +1,10 @@
1
+ (define powerset
2
+ [] -> [[]]
3
+ [X | Y] -> (let Powerset (powerset Y)
4
+ (append (cons-X-to-each-set X Powerset) Powerset)))
5
+
6
+ (define cons-X-to-each-set
7
+ _ [ ] -> [ ]
8
+ X [Y | Z] -> [[X | Y] | (cons-X-to-each-set X Z)])
9
+
10
+
@@ -0,0 +1,10 @@
1
+ (define prime?
2
+ X -> (prime* X (sqrt X) 2))
3
+
4
+ (define prime*
5
+ X Max Div -> false where (integer? (/ X Div))
6
+ X Max Div -> true where (> Div Max)
7
+ X Max Div -> (prime* X Max (+ 1 Div)))
8
+
9
+
10
+
@@ -0,0 +1,129 @@
1
+ (define l_interpreter
2
+ {A --> B}
3
+ _ -> (read_eval_print_loop (output "~%L interpreter ~%~%~%~%l-interp --> ~A~%"
4
+ (normal_form (input+ : l_formula)))))
5
+
6
+ (define read_eval_print_loop
7
+ {string --> A}
8
+ _ -> (read_eval_print_loop
9
+ (output "l-interp --> ~A~%"
10
+ (normal_form (input+ : l_formula)))))
11
+
12
+ (define normal_form
13
+ {l_formula --> l_formula}
14
+ X -> (fix ==> X))
15
+
16
+ (define ==>
17
+ {l_formula --> l_formula}
18
+ [= X Y] -> (let X* (normal_form X)
19
+ (let Y* (normal_form Y)
20
+ (if (or (eval_error? X*) (eval_error? Y*))
21
+ "error!"
22
+ (if (= X* Y*) true false))))
23
+ [[/. P X] Y] -> (let Match (match P (normal_form Y))
24
+ (if (no_match? Match)
25
+ "no match"
26
+ (sub Match X)))
27
+ [if X Y Z] -> (let X* (normal_form X)
28
+ (if (= X* true)
29
+ Y
30
+ (if (= X* false)
31
+ Z
32
+ "error!")))
33
+ [let X Y Z] -> [[/. X Z] Y]
34
+ [@p X Y] -> (let X* (normal_form X)
35
+ (let Y* (normal_form Y)
36
+ (if (or (eval_error? X*) (eval_error? Y*))
37
+ "error!"
38
+ [@p X* Y*])))
39
+ [cons X Y] -> (let X* (normal_form X)
40
+ (let Y* (normal_form Y)
41
+ (if (or (eval_error? X*) (eval_error? Y*))
42
+ "error!"
43
+ [cons X* Y*])))
44
+ [++ X] -> (successor (normal_form X))
45
+ [-- X] -> (predecessor (normal_form X))
46
+ \*[cases X1 | Xn] -> (let Case1 (normal_form X1)
47
+ (if (= Case1 "no match")
48
+ [cases | Xn]
49
+ Case1))
50
+ [cases] -> "error!"
51
+ [where X Y] -> [if X Y "no match"]
52
+ [y-combinator [/. X Y]] -> (replace X [y-combinator [/. X Y]] Y)
53
+ [X Y] -> (let X* (normal_form X)
54
+ (let Y* (normal_form Y)
55
+ (if (or (eval_error? X*) (eval_error? Y*))
56
+ "error!"
57
+ [X* Y*])))*\
58
+ X -> X)
59
+
60
+ (define eval_error?
61
+ {l_formula --> boolean}
62
+ "error!" -> true
63
+ "no match" -> true
64
+ _ -> false)
65
+
66
+ (define successor
67
+ {A --> l_formula}
68
+ X -> (+ 1 X) where (number? X)
69
+ _ -> "error!")
70
+
71
+ (define predecessor
72
+ {A --> l_formula}
73
+ X -> (- X 1) where (number? X)
74
+ _ -> "error!")
75
+
76
+ \* (spy +) *\
77
+
78
+ (define sub
79
+ {[(pattern * l_formula)] --> l_formula --> l_formula}
80
+ [] X -> X
81
+ [(@p Var Val) | Assoc] X -> (sub Assoc (replace Var Val X)))
82
+
83
+ (define match
84
+ {pattern --> l_formula --> (list (pattern * l_formula))}
85
+ P X -> [] where (== P X)
86
+ P X -> [(@p P X)] where (variable? P)
87
+ [cons P1 P2] [cons X Y] -> (let Match1 (match P1 X)
88
+ (if (no_match? Match1)
89
+ Match1
90
+ (let Match2 (match P2 Y)
91
+ (if (no_match? Match2)
92
+ Match2
93
+ (append Match1 Match2)))))
94
+ [@p P1 P2] [@p X Y] -> (let Match1 (match P1 X)
95
+ (if (no_match? Match1)
96
+ Match1
97
+ (let Match2 (match P2 Y)
98
+ (if (no_match? Match2)
99
+ Match2
100
+ (append Match1 Match2)))))
101
+
102
+ _ _ -> [(@p no matching)])
103
+
104
+ (define no_match?
105
+ {[(pattern * l_formula)] --> boolean}
106
+ [(@p no matching)] -> true
107
+ _ -> false)
108
+
109
+ (define replace
110
+ {pattern --> l_formula --> l_formula --> l_formula}
111
+ V W [let V* X Y] -> [let V* X Y] where (== V V*)
112
+ X Y X -> Y
113
+ V W [= X Y] -> [= (replace V W X) (replace V W Y)]
114
+ V W [/. P X] -> [/. P (replace V W X)] where (free? V P)
115
+ V W [if X Y Z] -> [if (replace V W X) (replace V W Y) (replace V W Z)]
116
+ V W [let X Y Z] -> [let X (replace V W Y) (replace V W Z)]
117
+ V W [@p X Y] -> [@p (replace V W X) (replace V W Y)]
118
+ \* V W [cons X Y] -> [cons (replace V W X) (replace V W Y)]
119
+ V W [cases | Xn] -> [cases | (map (/. Xi (replace V W Xi)) Xn)]
120
+ V W [where X Y] -> [where (replace V W X) (replace V W Y)]
121
+ V W [X Y] -> [(replace V W X) (replace V W Y)] *\
122
+ _ _ X -> X)
123
+
124
+ (define free?
125
+ {pattern --> pattern --> boolean}
126
+ P P -> false
127
+ P [cons P1 P2] -> (and (free? P P1) (free? P P2))
128
+ P [@p P1 P2] -> (and (free? P P1) (free? P P2))
129
+ _ _ -> true)
@@ -0,0 +1,68 @@
1
+ "Terms of Use
2
+ By 'derivative work' we understand it as defined by the US copyright law. We emphasise the following passage from the copyright act of the USA
3
+
4
+ Making minor changes or additions of little substance to a preexisting work will not qualify the work as a new version for copyright purposes.
5
+
6
+ By 'copyright holder' we understand Dr Mark Tarver, or, in the event of his decease, the committee appointed under the terms of his will to administer his intellectual estate.
7
+
8
+ By 'the software' we understand Shen and all the code used to implement it. We include both the original source code written in Shen, and the code derived from this code through compilation to other languages.
9
+
10
+ By 'Shen standard' we understand the latest standards for Shen laid down in Lambda Associates by the copyright holder.
11
+
12
+ By 'the user' we understand any person or group of persons, whether organised in a commercial company, cooperative or institution or not, that use the software. The use of 'he' and 'his' to refer to the user follows English usage, but makes no special assumptions about gender or plurality.
13
+
14
+ The License
15
+
16
+ The user is free to produce commercial applications with the software, to distribute these applications in source or binary form, and to charge monies for them as he sees fit and in concordance with the laws of the land subject to the following license.
17
+
18
+ 1. The license applies to all the software and all derived software and must appear on such.
19
+
20
+ 2. It is illegal to distribute the software without this license attached to it and use of the software implies agreement with the license as such. It is illegal for anyone who is not the copyright holder to tamper with or change the license.
21
+
22
+ 3. Neither the names of Lambda Associates or the copyright holder may be used to endorse or promote products built using the software without specific prior written permission from the copyright holder.
23
+
24
+ 4. That possession of this license does not confer on the copyright holder any special contractual obligation towards the user. That in no event shall the copyright holder be liable for any direct, indirect, incidental, special, exemplary or consequential damages (including but not limited to procurement of substitute goods or services, loss of use, data, or profits; or business interruption), however caused and on any theory of liability, whether in contract, strict liability or tort (including negligence) arising in any way out of the use of the software, even if advised of the possibility of such damage.
25
+
26
+ 5. It is permitted for the user to change the software, for the purpose of improving performance, correcting an error, or porting to a new platform, and distribute the modified version of Shen (hereafter the modified version) provided the resulting program conforms in all respects to the Shen standard and is issued under that title. The user must it clear with his distribution that he/she is the author of the changes and what these changes are and why.
27
+
28
+ 6. Derived versions of this software in whatever form are subject to the same restrictions. In particular it is not permitted to make derived copies of this software which do not conform to the Shen standard or appear under a different title.
29
+
30
+ 7. It is permitted to distribute versions of Shen which incorporate libraries, graphics or other facilities which are not part of the Shen standard.
31
+
32
+ The License in Detail
33
+
34
+ The user is free to produce commercial applications with the software, to distribute these applications in source or binary form, and to charge monies for them as he sees fit and in concordance with the laws of the land subject to the following license.
35
+
36
+ That's the $free part. You can write your own Shen software and put your own license on it and charge what you want and distribute it either as closed or open source. We'll come back to that.
37
+
38
+ 1. The license applies to all the software and all derived software and must appear on that software.
39
+
40
+ That means that the license applies to the Shen source code and the Kl source code which comes with the download. You will see that this code carries a copyright on the code. The concept of derivative is explained in US law as follows.
41
+
42
+ A 'derivative work' is a work based upon one or more pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which a work may be recast, transformed, or adapted. A work consisting of editorial revisions, annotations, elaborations, or other modifications which, as a whole, represent an original work of authorship, is a 'derivative work'.
43
+
44
+ To this we add that any computable mapping of the Shen source code and the Kl source code to another medium i.e. another language; counts as a derivative work in our understanding, and it is immaterial whether this mapping is done by a human being or by a computer. If you map Shen into Javascript by writing a compiler, then the resulting Javascript program carries the same license as the original and that license must appear on the code. If you retitle some of the functions using a global substitution it is a derivative work. If you copy it out in copperplate using a quill, it is derivative. In other words, the message and not the medium is important.
45
+
46
+ 2. It is illegal to distribute the software without this license attached to it and use of the software implies agreement with the license as such. It is illegal for anyone who is not the copyright holder to tamper with or change the license.
47
+
48
+ This is basic. You cannot remove this license or change it - only the copyright holder can do that.
49
+
50
+ 3. Neither the names of Lambda Associates or the copyright holder may be used to endorse or promote products built using the software without specific prior written permission from the copyright holder.
51
+
52
+ You cannot say 'My software is great because Mark Tarver recommends it' or 'Lambda Associates says this is really reliable' unless we did actually say that, and gave you the written permission to use our endorsement. That said, if you do write something really great in Shen, I'd be happy to endorse it and for you to use that endorsement.
53
+
54
+ 4. That possession of this license does not confer on the copyright holder any special contractual obligation towards the user. That in no event shall the copyright holder be liable for any direct, indirect, incidental, special, exemplary or consequential damages (including but not limited to procurement of substitute goods or services, loss of use, data, or profits; or business interruption), however caused and on any theory of liability, whether in contract, strict liability or tort (including negligence) arising in any way out of the use of the software, even if advised of the possibility of such damage.
55
+
56
+ This is the usual disclaimer. It protects us from a lawsuit in case anything goes wrong with our software. However Shen is based on a design with 20 years R&D; it has been very thoroughly tested by myself and by the people who have ported it to other platforms. So in all you are pretty safe here.
57
+
58
+ 5. It is permitted for the user to change the software, for the purpose of improving performance, correcting an error, or porting to a new platform, and distribute the modified version of Shen (hereafter the modified version) provided the resulting program conforms in all respects to the Shen standard and is issued under that title and the original license. The user must it clear with his distribution that he/she is the author of the changes and what these changes are and why.
59
+
60
+ Shen sources are readable for several reasons. The first is that we want to allow people to read our code and correct mistakes. The second is that people porting Shen to different OSes and different platforms need open access to the code to do the porting. The last is we allow people to improve the efficiency of our code by changing it - as long as it then still works i.e. it conforms to the spec. You have to put your name on the changes you make, because, in the event that something goes wrong, we cannot take the moral responsibility for those changes. It should be obvious (I hope) that optimising a small piece of code does not change the license or allow you to change the license. The resulting work is still derivative.
61
+
62
+ 6. Derived versions of this software in whatever form are subject to the same restrictions. In particular it is not permitted to make derived copies of this software which do not conform to the Shen standard or appear under a different title.
63
+
64
+ Again this emphasises what we said in explicating 1. This point just says you cannot evade the license by simply retitling and reselling our code under a different title e.g. Shine.
65
+
66
+ 7. It is permitted to distribute versions of Shen which incorporate libraries, graphics or other facilities which are not part of the Shen standard.
67
+
68
+ This means you are free to add things to Shen which are not part of the standard and you can distribute that work under the Shen title."