source: project/wiki/eggref/5/shen @ 37161

Last change on this file since 37161 was 37161, checked in by svnwiki, 7 weeks ago

Anonymous wiki edit for IP [220.233.44.123]:

File size: 3.1 KB
Line 
1== shen
2
3A port of the Shen programming language for Chicken Scheme.
4
5[[toc:]]
6
7=== Shen
8
9Shen is a hosted language that comes with a macro system, prolog, optional type system based on sequent calculus and a YACC. 
10
11=== Egg Author
12
13David Ireland (djireland79 at gmail dot com)
14
15=== Shen Documentation
16
17The best source of information for Shen programming is the
18[[https://www.amazon.com/Book-Shen-third-Mark-Tarver/dp/1784562130/ref=sr_1_1?ie=UTF8&qid=1548832486&sr=8-1&keywords=the+book+of+shen| The Book of Shen]] and the [[http://www.shenlanguage.org/|Shen web site]]
19.
20=== Egg Source Code
21
22[[https://sarnath.xyz/chicken-shen |Chicken-Shen]]
23
24=== chicken-shen Usage
25
26<enscript highlight="bash">
27$ chicken-shen -h
28
29Usage: shen [options] [...args...]
30  -h, --help          : Prints help and exits
31  -l, --load <file>   : Loads Shen <file>
32  -e, --eval <string> : Evaluates <string>
33  -r, --repl          : Run the REPL, even if -l or -e are provided
34Any additional arguments are passed to the Shen system in
35the variable shen-wasp.*argv*
36</enscript>
37
38==== Starting the REPL from a terminal
39
40<enscript highlight="bash">
41$ chicken-shen
42</enscript>
43
44<enscript highlight="bash">
45Shen, copyright (C) 2010-2015 Mark Tarver
46www.shenlanguage.org, Shen 21.1
47running under Scheme, implementation: Chicken
48port 0.1 ported by David Ireland
49
50(0-)
51</enscript>
52
53=== Example Shen Code
54
55==== Symbols
56
57Unlike Chicken Scheme symbols are implicitly quoted thus no ' is needed.
58<enscript highlight="lisp">
59(0-) HI
60HI
61</enscript>
62
63==== Basic List processing
64
65<enscript highlight="lisp">
66(define factorial
67        0 -> 1
68        X -> (* X (factorial (- X 1))))
69</enscript>
70
71<enscript highlight="lisp">
72(define total
73        [] -> 0
74        [X | Y] -> (+ X (total Y)))
75</enscript>
76
77
78<enscript highlight="lisp">
79(define triples
80        [] -> []
81        [W X Y | Z] -> [[W X Y] | (triples Z)])
82</enscript>
83
84==== YACC
85<enscript highlight="lisp">
86(defcc <binary?>
87X <binary?> := true where (element? X [0 1]);
88X := true where (element? X [0 1]);
89<e> := false;)
90</enscript>
91
92==== Prolog
93
94<enscript highlight="lisp">
95(defprolog member
96xxX [X | _] <--;
97xxX [_ | Y] <-- (member X Y);)
98</enscript>
99
100==== Type System
101
102The type system is optional and disabled by default. It can be enabled using:
103<enscript highlight="lisp"> 
104(0-) (tc +)
105true
106
107(1+) 5
1085 : number
109
110(2+) "ABC"
111"ABC" : string
112
113(3+) (+ 1 1)
1142 : number
115</enscript>
116
117and off with:
118
119<enscript highlight="lisp"> 
120(4+) (tc -)
121false : boolean
122
123(5-) 5
1245
125
126(6-) "ABC"
127"ABC"
128
129(7-) (+ 1 1)
1302
131</enscript>
132
133
134==== Calling native Scheme code
135
136Calling native Chicken procedures is done by prefixing 'lisp' to the procedure name. An example of calling Chicken's print is given below.
137
138<enscript highlight="bash">
139Shen, copyright (C) 2010-2015 Mark Tarver
140www.shenlanguage.org, Shen 21.1
141running under Scheme, implementation: Chicken
142port 0.1 ported by David Ireland
143
144(0-) (lisp.print "Hello World")
145Hello World
146#<unspecified>
147
148(1-)
149</enscript>
150
151
152=== About this egg
153
154==== License
155BSD Clause 3
156
157==== Dependencies
158srfi-1
159srfi-13
160
161==== Versions
162; [[https:sarnath.xyz/chicken-shen/tarball/chicken-shen-0.1.tar.gz|0.1]] :
163
Note: See TracBrowser for help on using the repository browser.