Use singleton values for nil, true and false
[jackhill/mal.git] / README.md
CommitLineData
60154d24
JM
1# mal - Make a Lisp
2
f9e6bb80
JM
3[![Build Status](https://travis-ci.org/kanaka/mal.svg?branch=master)](https://travis-ci.org/kanaka/mal)
4
bcddc3e4
JM
5## Description
6
27696157 7Mal is a Clojure inspired Lisp interpreter.
b76aa73b 8
5c34565f 9Mal is implemented in 58 languages:
bcddc3e4 10
6faafa00 11* Ada
8c7587af 12* GNU awk
edc3b064 13* Bash shell
bcddc3e4 14* C
73fc9366 15* C++
edc3b064 16* C#
385a08eb 17* ChucK
edc3b064 18* Clojure
891c3f3b 19* CoffeeScript
6c4dede1 20* Crystal
f82cb965 21* D
bb526975 22* Elixir
e0b7f668 23* Emacs Lisp
2cc3804b 24* Erlang
88e934b6 25* ES6 (ECMAScript 6 / ECMAScript 2015)
6f78381f 26* F#
0fe47e88 27* Factor
96032890 28* Forth
1771ab50 29* Go
7ab0f63e 30* Groovy
7c6882f2 31* GNU Guile
b76aa73b 32* Haskell
33dec7af 33* Haxe
61f69fba 34* Io
bcddc3e4 35* Java
39381792
JM
36* JavaScript ([Online Demo](http://kanaka.github.io/mal))
37* Julia
53c2ea70 38* Kotlin
4eb88ef2 39* Logo
9d42904e 40* Lua
bcddc3e4
JM
41* GNU Make
42* mal itself
8a9d0a8a 43* MATLAB
1218ce98 44* [miniMAL](https://github.com/kanaka/miniMAL)
a2cd0a3a 45* Nim
0067158f 46* Object Pascal
7cae6e6f 47* Objective C
bc6448bc 48* OCaml
6301e0b6 49* Perl
a7081401 50* Perl 6
edc3b064 51* PHP
b88bb764
JM
52* PL/pgSQL (Postgres)
53* PL/SQL (Oracle)
edc3b064 54* Postscript
5c34565f 55* PowerShell
edc3b064 56* Python
23e38cd2 57* RPython
9b3362e8 58* R
f5223195 59* Racket
8adb0827 60* Ruby
abdd56eb 61* Rust
821930db 62* Scala
8b142f08 63* Swift
ea1395aa 64* Swift 3
54d9903c 65* Tcl
36e91db4 66* VHDL
50a964ce 67* Vimscript
ee7cd585 68* Visual Basic.NET
bcddc3e4
JM
69
70
bd08422d
JM
71Mal is a learning tool. See the [make-a-lisp process
72guide](process/guide.md). Each implementation of mal is separated into
7311 incremental, self-contained (and testable) steps that demonstrate
74core concepts of Lisp. The last step is capable of self-hosting
75(running the mal implementation of mal).
bcddc3e4
JM
76
77The mal (make a lisp) steps are:
78
0f4ca9d1
JM
79* [step0_repl](process/guide.md#step0)
80* [step1_read_print](process/guide.md#step1)
81* [step2_eval](process/guide.md#step2)
82* [step3_env](process/guide.md#step3)
83* [step4_if_fn_do](process/guide.md#step4)
84* [step5_tco](process/guide.md#step5)
85* [step6_file](process/guide.md#step6)
86* [step7_quote](process/guide.md#step7)
87* [step8_macros](process/guide.md#step8)
88* [step9_try](process/guide.md#step9)
90f618cb 89* [stepA_mal](process/guide.md#stepA)
bcddc3e4
JM
90
91
92Mal was presented publicly for the first time in a lightning talk at
93Clojure West 2014 (unfortunately there is no video). See
dede32ba
JM
94examples/clojurewest2014.mal for the presentation that was given at the
95conference (yes the presentation is a mal program). At Midwest.io
962015, Joel Martin gave a presentation on Mal titled "Achievement
97Unlocked: A Better Path to Language Learning".
98[Video](https://www.youtube.com/watch?v=lgyOAiRtZGw),
99[Slides](http://kanaka.github.io/midwest.io.mal/).
60154d24 100
144f2b6a 101If you are interesting in creating a mal implementation (or just
bd62ff74 102interested in using mal for something), please drop by the #mal
144f2b6a
JM
103channel on freenode. In addition to the [make-a-lisp process
104guide](process/guide.md) there is also a [mal/make-a-lisp
105FAQ](docs/FAQ.md) where I attempt to answer some common questions.
106
60154d24
JM
107## Building/running implementations
108
5b207de7
JM
109The simplest way to run any given implementation is to use docker.
110Every implementation has a docker image pre-built with language
111dependencies installed. You can launch the REPL using a convenience
112target in the top level Makefile (where IMPL is the implementation
113directory name and stepX is the step to run):
114
115```
116make DOCKERIZE=1 "repl^IMPL^stepX"
117 # OR stepA is the default step:
118make DOCKERIZE=1 "repl^IMPL"
119```
120
121
6faafa00
CM
122### Ada
123
7b458a65
JM
124*The Ada implementation was created by [Chris Moore](https://github.com/zmower)*
125
126The Ada implementation was developed with GNAT 4.9 on debian. It also
127compiles unchanged on windows if you have windows versions of git,
128GNAT and (optionally) make. There are no external dependencies
129(readline not implemented).
6faafa00
CM
130
131```
132cd ada
133make
134./stepX_YYY
135```
136
8c7587af
MK
137### GNU awk
138
4c58cd4e 139*The GNU awk implementation was created by [Miutsuru kariya](https://github.com/kariya-mitsuru)*
390d5829 140
8c7587af
MK
141The GNU awk implementation of mal has been tested with GNU awk 4.1.1.
142
143```
144cd gawk
145gawk -O -f stepX_YYY.awk
146```
147
bcddc3e4 148### Bash 4
60154d24
JM
149
150```
151cd bash
152bash stepX_YYY.sh
153```
154
bcddc3e4 155### C
60154d24 156
01c97316 157The C implementation of mal requires the following libraries (lib and
6b3ecaa7
DM
158header packages): glib, libffi6, libgc, and either the libedit or GNU readline
159library.
54c75382 160
60154d24
JM
161```
162cd c
163make
164./stepX_YYY
165```
166
73fc9366
JM
167### C++
168
a848d783
JM
169*The C++ implementation was created by [Stephen Thirlwall (sdt)](https://github.com/sdt)*
170
73fc9366
JM
171The C++ implementation of mal requires g++-4.9 or clang++-3.5 and
172a readline compatible library to build. See the `cpp/README.md` for
173more details:
174
175```
176cd cpp
177make
178 # OR
179make CXX=clang++-3.5
180./stepX_YYY
181```
182
183
9b1563a3 184### C# ###
edc3b064
JM
185
186The C# implementation of mal has been tested on Linux using the Mono
187C# compiler (mcs) and the Mono runtime (version 2.10.8.1). Both are
188required to build and run the C# implementation.
189
190```
191cd cs
192make
ee7cd585 193mono ./stepX_YYY.exe
edc3b064
JM
194```
195
385a08eb
VS
196### ChucK
197
198*The ChucK implementation was created by [Vasilij Schneidermann](https://github.com/wasamasa)*
199
200The ChucK implementation has been tested with ChucK 1.3.5.2 on Arch
201Linux.
202
203```
204cd chuck
205./run
206```
edc3b064 207
bcddc3e4 208### Clojure
60154d24 209
aa716df6
JM
210For the most part the Clojure implementation requires Clojure 1.5,
211however, to pass all tests, Clojure 1.8.0-RC4 is required.
212
60154d24
JM
213```
214cd clojure
215lein with-profile +stepX trampoline run
216```
217
891c3f3b
JM
218### CoffeeScript
219
220```
221sudo npm install -g coffee-script
222cd coffee
223coffee ./stepX_YYY
224```
225
58b84dd5 226### Crystal
227
6427adea 228*The Crystal implementation of mal was created by [Linda_pp](https://github.com/rhysd)*
6c4dede1 229
d10848bb 230The Crystal implementation of mal has been tested with Crystal 0.18.4.
6c4dede1 231
58b84dd5 232```
233cd crystal
234crystal run ./stepX_YYY.cr
6c4dede1
JM
235 # OR
236make # needed to run tests
237./stepX_YYY
58b84dd5 238```
239
f82cb965
DM
240### D
241
242*The D implementation was created by [Dov Murik](https://github.com/dubek)*
243
244The D implementation of mal was tested with GDC 4.8. It requires the GNU
245readline library.
246
247```
248cd d
249make
250./stepX_YYY
251```
252
e0b7f668
VS
253### Emacs Lisp
254
255*The Emacs Lisp implementation was created by [Vasilij Schneidermann](https://github.com/wasamasa)*
256
257The Emacs Lisp implementation of mal has been tested with Emacs 24.3
258and 24.5. While there is very basic readline editing (`<backspace>`
259and `C-d` work, `C-c` cancels the process), it is recommended to use
260`rlwrap`.
261
262```
263cd elisp
264emacs -Q --batch --load stepX_YYY.el
265# with full readline support
266rlwrap emacs -Q --batch --load stepX_YYY.el
267```
268
bb526975 269### Elixir
270
271*The Elixir implementation was created by [Martin Ek (ekmartin)](https://github.com/ekmartin)*
272
273The Elixir implementation of mal has been tested with Elixir 1.0.5.
274
275```
276cd elixir
df2ca97b 277mix stepX_YYY
278# Or with readline/line editing functionality:
bb526975 279iex -S mix stepX_YYY
280```
281
2cc3804b
NF
282### Erlang
283
425ef3d7
JM
284*The Erlang implementation was created by [Nathan Fiedler (nlfiedler)](https://github.com/nlfiedler)*
285
82484631
JM
286The Erlang implementation of mal requires [Erlang/OTP R17](http://www.erlang.org/download.html)
287and [rebar](https://github.com/rebar/rebar) to build.
2cc3804b
NF
288
289```
290cd erlang
425ef3d7
JM
291make
292 # OR
293MAL_STEP=stepX_YYY rebar compile escriptize # build individual step
2cc3804b
NF
294./stepX_YYY
295```
296
88e934b6
JM
297### ES6 (ECMAScript 6 / ECMAScript 2015)
298
299The ES6 implementation uses the [babel](https://babeljs.io) compiler
300to generate ES5 compatible JavaScript. The generated code has been
301tested with Node 0.12.4.
302
303```
304cd es6
305make
306node build/stepX_YYY.js
307```
308
309
6f78381f
PS
310### F# ###
311
312*The F# implementation was created by [Peter Stephens (pstephens)](https://github.com/pstephens)*
313
314The F# implementation of mal has been tested on Linux using the Mono
315F# compiler (fsharpc) and the Mono runtime (version 3.12.1). The mono C#
206a1657 316compiler (mcs) is also necessary to compile the readline dependency. All are
6f78381f
PS
317required to build and run the F# implementation.
318
319```
320cd fsharp
321make
322mono ./stepX_YYY.exe
323```
324
5a53c643
JL
325### Factor
326
44c8a524 327*The Factor implementation was created by [Jordan Lewis (jordanlewis)](https://github.com/jordanlewis)*
5a53c643 328
0fe47e88 329The Factor implementation of mal has been tested with Factor 0.97
07eb827b 330([factorcode.org](http://factorcode.org)).
0fe47e88 331
5a53c643
JL
332```
333cd factor
199b1ce7 334FACTOR_ROOTS=. factor -run=stepX_YYY
5a53c643
JL
335```
336
96032890
C
337### Forth
338
a848d783
JM
339*The Forth implementation was created by [Chris Houser (chouser)](https://github.com/chouser)*
340
96032890
C
341```
342cd forth
343gforth stepX_YYY.fs
344```
345
1771ab50
JM
346### Go
347
0fe47e88 348The Go implementation of mal requires that go is installed on on the
fd888612
JM
349path. The implementation has been tested with Go 1.3.1.
350
1771ab50
JM
351```
352cd go
353make
354./stepX_YYY
355```
356
357
7ab0f63e
JM
358### Groovy
359
360The Groovy implementation of mal requires Groovy to run and has been
361tested with Groovy 1.8.6.
362
363```
364cd groovy
365make
366groovy ./stepX_YYY.groovy
367```
368
5a9cda80
JM
369### GNU Guile 2.1+
370
371*The Guile implementation was created by [Mu Lei (NalaGinrut)](https://github.com/NalaGinrut).*
372
373```
374cd guile
375guile -L ./ stepX_YYY.scm
376```
7ab0f63e 377
b76aa73b
JM
378### Haskell
379
2988d38e 380Install the Haskell compiler (ghc/ghci), the Haskell platform and
5400d4bf
JM
381either the editline package (BSD) or the readline package (GPL). On
382Ubuntu these packages are: ghc, haskell-platform,
383libghc-readline-dev/libghc-editline-dev
b76aa73b
JM
384
385```
386cd haskell
387make
388./stepX_YYY
389```
390
33dec7af
JM
391### Haxe
392
393The Haxe implementation of mal requires Haxe version 3.2 to compile.
394Four different Haxe targets are supported: Neko, Python, C++, and
395JavaScript.
396
397```
398cd haxe
399# Neko
400make all-neko
401neko ./stepX_YYY.n
402# Python
403make all-python
404python3 ./stepX_YYY.py
405# C++
406make all-cpp
407./cpp/stepX_YYY
408# JavaScript
409make all-js
410node ./stepX_YYY.js
411```
412
61f69fba
DM
413### Io
414
415*The Io implementation was created by [Dov Murik](https://github.com/dubek)*
416
417The Io implementation of mal has been tested with Io version 20110905.
418
419```
420cd io
421io ./stepX_YYY.io
422```
b76aa73b 423
bcddc3e4 424### Java 1.7
60154d24 425
01c97316
JM
426The Java implementation of mal requires maven2 to build.
427
60154d24
JM
428```
429cd java
430mvn compile
431mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY
432 # OR
433mvn -quiet exec:java -Dexec.mainClass=mal.stepX_YYY -Dexec.args="CMDLINE_ARGS"
434```
435
39381792 436### JavaScript/Node
60154d24
JM
437
438```
439cd js
54c75382 440npm update
60154d24
JM
441node stepX_YYY.js
442```
443
39381792
JM
444### Julia
445
82484631 446The Julia implementation of mal requires Julia 0.4.
39381792
JM
447
448```
449cd julia
450julia stepX_YYY.jl
451```
452
53c2ea70
JFI
453### Kotlin
454
455*The Kotlin implementation was created by [Javier Fernandez-Ivern](https://github.com/ivern)*
456
75787d77 457The Kotlin implementation of mal has been tested with Kotlin 1.0.
53c2ea70
JFI
458
459```
460cd kotlin
461make
462java -jar stepX_YYY.jar
463```
464
4eb88ef2
DM
465### Logo
466
467*The Logo implementation was created by [Dov Murik](https://github.com/dubek)*
468
469The Logo implementation of mal has been tested with UCBLogo 6.0.
470
471```
472cd logo
473logo stepX_YYY.lg
474```
475
9d42904e
JM
476### Lua
477
8a9d0a8a 478Running the Lua implementation of mal requires lua 5.1 or later,
9d42904e
JM
479luarocks and the lua-rex-pcre library installed.
480
481```
482cd lua
483make # to build and link linenoise.so
484./stepX_YYY.lua
485```
486
bcddc3e4 487### Mal
60154d24
JM
488
489Running the mal implementation of mal involves running stepA of one of
490the other implementations and passing the mal step to run as a command
5d446bd8 491line argument.
60154d24
JM
492
493```
494cd IMPL
495IMPL_STEPA_CMD ../mal/stepX_YYY.mal
496
497```
498
bcddc3e4 499### GNU Make 3.81
60154d24
JM
500
501```
502cd make
503make -f stepX_YYY.mk
504```
505
de69b639 506### Nim 0.11.0
a2cd0a3a 507
a848d783
JM
508*The Nim implementation was created by [Dennis Felsing (def-)](https://github.com/def-)*
509
de69b639 510Running the Nim implementation of mal requires Nim 0.11.0 or later.
a2cd0a3a 511
512```
513cd nim
514make
515 # OR
516nimble build
517./stepX_YYY
518```
519
0067158f
JM
520### Object Pascal
521
522The Object Pascal implementation of mal has been built and tested on
523Linux using the Free Pascal compiler version 2.6.2 and 2.6.4.
524
525```
526cd objpascal
527make
528./stepX_YYY
529```
530
7cae6e6f
JM
531### Objective C
532
533The Objective C implementation of mal has been built and tested on
2faae94c
JM
534Linux using clang/LLVM 3.6. It has also been built and tested on OS
535X using XCode 7.
7cae6e6f
JM
536
537```
538cd objc
539make
540./stepX_YYY
541```
542
bc6448bc
C
543### OCaml 4.01.0
544
a848d783
JM
545*The OCaml implementation was created by [Chris Houser (chouser)](https://github.com/chouser)*
546
bc6448bc
C
547```
548cd ocaml
549make
550./stepX_YYY
551```
552
8a9d0a8a
JM
553### MATLAB
554
555The MATLAB implementation of mal has been tested with MATLAB version
556R2014a on Linux. Note that MATLAB is a commercial product. It should
557be fairly simple to support GNU Octave once it support classdef object
558syntax.
559
560```
561cd matlab
562./stepX_YYY
563matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY();quit;"
564 # OR with command line arguments
565matlab -nodisplay -nosplash -nodesktop -nojvm -r "stepX_YYY('arg1','arg2');quit;"
566```
567
1218ce98
JM
568### miniMAL
569
570[miniMAL](https://github.com/kanaka/miniMAL) is small Lisp interpreter
571implemented in less than 1024 bytes of JavaScript. To run the miniMAL
572implementation of mal you need to download/install the miniMAL
573interpreter (which requires Node.js).
574```
1218ce98 575cd miniMAL
478fd9ce
JM
576# Download miniMAL and dependencies
577npm install
578export PATH=`pwd`/node_modules/minimal-lisp/:$PATH
579# Now run mal implementation in miniMAL
1218ce98
JM
580miniMAL ./stepX_YYY
581```
582
9b1563a3 583### Perl 5.8
9e5b2151
JM
584
585For readline line editing support, install Term::ReadLine::Perl or
586Term::ReadLine::Gnu from CPAN.
587
588```
589cd perl
590perl stepX_YYY.pl
591```
592
a7081401
HÖS
593### Perl 6
594
595*The Perl 6 implementation was created by [Hinrik Örn Sigurðsson](https://github.com/hinrik)*
596
597The Perl 6 implementation was tested on Rakudo Perl 6 2016.04.
598
599```
600cd perl6
601perl6 stepX_YYY.pl
602```
9e5b2151 603
bcddc3e4 604### PHP 5.3
60154d24 605
01c97316
JM
606The PHP implementation of mal requires the php command line interface
607to run.
608
60154d24
JM
609```
610cd php
611php stepX_YYY.php
612```
613
b25bf8d8
JM
614### PL/pgSQL (Postgres SQL Procedural Language)
615
b88bb764
JM
616The PL/pgSQL implementation of mal requires a running Postgres server
617(the "kanaka/mal-test-plpgsql" docker image automatically starts
618a Postgres server). The implementation connects to the Postgres server
619and create a database named "mal" to store tables and stored
620procedures. The wrapper script uses the psql command to connect to the
621server and defaults to the user "postgres" but this can be overridden
622with the PSQL_USER environment variable. A password can be specified
623using the PGPASSWORD environment variable. The implementation has been
624tested with Postgres 9.4.
b25bf8d8
JM
625
626```
627cd plpgsql
628./wrap.sh stepX_YYY.sql
b88bb764
JM
629 # OR
630PSQL_USER=myuser PGPASSWORD=mypass ./wrap.sh stepX_YYY.sql
631```
632
633### PL/SQL (Oracle SQL Procedural Language)
634
635The PL/pgSQL implementation of mal requires a running Oracle DB
636server (the "kanaka/mal-test-plsql" docker image automatically
637starts an Oracle Express server). The implementation connects to the
638Oracle server to create types, tables and stored procedures. The
639default SQL*Plus logon value (username/password@connect_identifier) is
640"system/oracle" but this can be overridden with the ORACLE_LOGON
641environment variable. The implementation has been tested with Oracle
642Express Edition 11g Release 2. Note that any SQL*Plus connection
643warnings (user password expiration, etc) will interfere with the
644ability of the wrapper script to communicate with the DB.
645
646```
647cd plsql
648./wrap.sh stepX_YYY.sql
649 # OR
650ORACLE_LOGON=myuser/mypass@ORCL ./wrap.sh stepX_YYY.sql
b25bf8d8
JM
651```
652
5c34565f
JM
653### Postscript Level 2/3
654
655The Postscript implementation of mal requires ghostscript to run. It
656has been tested with ghostscript 9.10.
657
658```
659cd ps
660gs -q -dNODISPLAY -I./ stepX_YYY.ps
661```
662
663### PowerShell
664
665The PowerShell implementation of mal requires the PowerShell script
666language. It has been tested with PowerShell 6.0.0 Alpha 9 on Linux.
667
668```
669cd powershell
670powershell ./stepX_YYY.ps1
671```
672
23e38cd2 673### Python (2.X or 3.X)
60154d24
JM
674
675```
676cd python
677python stepX_YYY.py
678```
8adb0827 679
23e38cd2
JM
680### RPython
681
682You must have [rpython](https://rpython.readthedocs.org/) on your path
683(included with [pypy](https://bitbucket.org/pypy/pypy/)).
684
685```
686cd rpython
4e8d7c28 687make # this takes a very long time
23e38cd2
JM
688./stepX_YYY
689```
690
9b3362e8
JM
691### R
692
693The R implementation of mal requires R (r-base-core) to run.
694
695```
696cd r
9d42904e 697make libs # to download and build rdyncall
f5223195
JM
698Rscript stepX_YYY.r
699```
700
701### Racket (5.3)
702
703The Racket implementation of mal requires the Racket
704compiler/interpreter to run.
705
706```
707cd racket
3796240a 708./stepX_YYY.rkt
9b3362e8
JM
709```
710
107d9694 711### Ruby (1.9+)
8adb0827
JM
712
713```
714cd ruby
715ruby stepX_YYY.rb
716```
592eb5cf 717
9106a221 718### Rust (1.0.0 nightly)
abdd56eb
JM
719
720The rust implementation of mal requires the rust compiler and build
721tool (cargo) to build.
722
723```
724cd rust
bbeb1b87 725cargo run --release --bin stepX_YYY
abdd56eb
JM
726```
727
821930db
JM
728### Scala ###
729
730Install scala and sbt (http://www.scala-sbt.org/0.13/tutorial/Installing-sbt-on-Linux.html):
731
732```
733cd scala
734sbt 'run-main stepX_YYY'
735 # OR
736sbt compile
737scala -classpath target/scala*/classes stepX_YYY
738```
739
2539e6af
KR
740### Swift
741
a848d783
JM
742*The Swift implementation was created by [Keith Rollin](https://github.com/keith-rollin)*
743
e31349f6
KR
744The Swift implementation of mal requires the Swift 2.0 compiler (XCode
7457.0) to build. Older versions will not work due to changes in the
746language and standard library.
8b142f08 747
2539e6af
KR
748```
749cd swift
750make
751./stepX_YYY
752```
753
ea1395aa
JM
754### Swift 3
755
756The Swift 3 implementation of mal requires the Swift 3.0 compiler. It
a3a6f680 757has been tested with Swift 3 Preview 3.
ea1395aa
JM
758
759```
760cd swift3
761make
762./stepX_YYY
763```
764
54d9903c
DM
765### Tcl 8.6
766
767*The Tcl implementation was created by [Dov Murik](https://github.com/dubek)*
768
769The Tcl implementation of mal requires Tcl 8.6 to run. For readline line
770editing support, install tclreadline.
771
772```
773cd tcl
774tclsh ./stepX_YYY.tcl
775```
776
36e91db4
DM
777### VHDL
778
779*The VHDL implementation was created by [Dov Murik](https://github.com/dubek)*
780
781The VHDL implementation of mal has been tested with GHDL 0.29.
782
783```
784cd vhdl
785make
786./run_vhdl.sh ./stepX_YYY
787```
788
50a964ce
DM
789### Vimscript
790
791*The Vimscript implementation was created by [Dov Murik](https://github.com/dubek)*
792
793The Vimscript implementation of mal requires Vim to run. It has been tested
794with Vim 7.4.
795
796```
797cd vimscript
798./run_vimscript.sh ./stepX_YYY.vim
799```
800
ee7cd585
JM
801### Visual Basic.NET ###
802
803The VB.NET implementation of mal has been tested on Linux using the Mono
804VB compiler (vbnc) and the Mono runtime (version 2.10.8.1). Both are
805required to build and run the VB.NET implementation.
806
807```
808cd vb
809make
810mono ./stepX_YYY.exe
811```
812
813
814
592eb5cf
JM
815## Running tests
816
294aba2c
JM
817### Functional tests
818
eaa6ceb4 819The are over 600 generic functional tests (for all implementations)
294aba2c
JM
820in the `tests/` directory. Each step has a corresponding test file
821containing tests specific to that step. The `runtest.py` test harness
bd62ff74
JM
822launches a Mal step implementation and then feeds the tests one at
823a time to the implementation and compares the output/return value to
824the expected output/return value.
592eb5cf
JM
825
826To simplify the process of running tests, a top level Makefile is
827provided with convenient test targets.
828
829* To run all the tests across all implementations (be prepared to wait):
830
831```
832make test
833```
834
835* To run all tests against a single implementation:
836
837```
e5737b08 838make "test^IMPL"
592eb5cf
JM
839
840# e.g.
e5737b08
SL
841make "test^clojure"
842make "test^js"
592eb5cf
JM
843```
844
845* To run tests for a single step against all implementations:
846
847```
e5737b08 848make "test^stepX"
592eb5cf
JM
849
850# e.g.
e5737b08
SL
851make "test^step2"
852make "test^step7"
592eb5cf
JM
853```
854
4c58cd4e 855* To run tests for a specific step against a single implementation:
592eb5cf
JM
856
857```
e5737b08 858make "test^IMPL^stepX"
592eb5cf
JM
859
860# e.g
e5737b08
SL
861make "test^ruby^step3"
862make "test^ps^step4"
592eb5cf 863```
fd888612 864
294aba2c
JM
865### Self-hosted functional tests
866
867* To run the functional tests in self-hosted mode, you specify `mal`
868 as the test implementation and use the `MAL_IMPL` make variable
869 to change the underlying host language (default is JavaScript):
870```
e5737b08 871make MAL_IMPL=IMPL "test^mal^step2"
294aba2c
JM
872
873# e.g.
e5737b08
SL
874make "test^mal^step2" # js is default
875make MAL_IMPL=ruby "test^mal^step2"
876make MAL_IMPL=python "test^mal^step2"
294aba2c
JM
877```
878
854cf2a6
DM
879### Starting the REPL
880
881* To start the REPL of an implementation in a specific step:
882
883```
884make "repl^IMPL^stepX"
885
886# e.g
887make "repl^ruby^step3"
888make "repl^ps^step4"
889```
890
891* If you omit the step, then `stepA` is used:
892
893```
894make "repl^IMPL"
895
896# e.g
897make "repl^ruby"
898make "repl^ps"
899```
900
901* To start the REPL of the self-hosted implementation, specify `mal` as the
902 REPL implementation and use the `MAL_IMPL` make variable to change the
903 underlying host language (default is JavaScript):
904```
905make MAL_IMPL=IMPL "repl^mal^stepX"
906
907# e.g.
908make "repl^mal^step2" # js is default
909make MAL_IMPL=ruby "repl^mal^step2"
910make MAL_IMPL=python "repl^mal"
911```
294aba2c
JM
912
913### Performance tests
914
8569b2af
JM
915Warning: These performance tests are neither statistically valid nor
916comprehensive; runtime performance is a not a primary goal of mal. If
917you draw any serious conclusions from these performance tests, then
918please contact me about some amazing oceanfront property in Kansas
919that I'm willing to sell you for cheap.
920
294aba2c
JM
921* To run performance tests against a single implementation:
922```
e5737b08 923make "perf^IMPL"
294aba2c
JM
924
925# e.g.
e5737b08 926make "perf^js"
294aba2c
JM
927```
928
929* To run performance tests against all implementations:
930```
e5737b08 931make "perf"
294aba2c
JM
932```
933
934### Generating language statistics
935
4c58cd4e 936* To report line and byte statistics for a single implementation:
294aba2c 937```
e5737b08 938make "stats^IMPL"
294aba2c
JM
939
940# e.g.
e5737b08 941make "stats^js"
294aba2c
JM
942```
943
4c58cd4e 944* To report line and bytes statistics for general Lisp code (env, core
294aba2c
JM
945 and stepA):
946```
e5737b08 947make "stats-lisp^IMPL"
294aba2c
JM
948
949# e.g.
e5737b08 950make "stats-lisp^js"
294aba2c
JM
951```
952
5b207de7 953## Dockerized testing
75363567 954
5b207de7
JM
955Every implementation directory contains a Dockerfile to create
956a docker image containing all the dependencies for that
957implementation. In addition, the top-level Makefile contains support
958for running the tests target (and perf, stats, repl, etc) within
959a docker container for that implementation by passing *"DOCKERIZE=1"*
960on the make command line. For example:
75363567 961
75363567 962```
5b207de7 963make DOCKERIZE=1 "test^js^step3"
75363567
JM
964```
965
5b207de7
JM
966Existing implementations already have docker images built and pushed
967to the docker registry. However, if
968you wish to build or rebuild a docker image locally, the toplevel
969Makefile provides a rule for building docker images:
970
75363567 971```
5b207de7
JM
972make "docker-build^IMPL"
973```
974
75363567
JM
975
976**Notes**:
5b207de7
JM
977* Docker images are named *"kanaka/mal-test-IMPL"*
978* JVM-based language implementations (Groovy, Java, Clojure, Scala):
979 you will probably need to run these implementations once manually
980 first (make DOCKERIZE=1 "repl^IMPL")before you can run tests because
981 runtime dependencies need to be downloaded to avoid the tests timing
982 out. These dependencies are download to dot-files in the /mal
983 directory so they will persist between runs.
75363567 984
294aba2c 985
fd888612
JM
986## License
987
988Mal (make-a-lisp) is licensed under the MPL 2.0 (Mozilla Public
989License 2.0). See LICENSE.txt for more details.