Skip to content

Commit b68d3a8

Browse files
committed
elixir.2: provide new elixir implementation
1 parent 2bbfaa5 commit b68d3a8

35 files changed

Lines changed: 3490 additions & 3 deletions

IMPLS.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ IMPL:
2222
- {IMPL: dart}
2323
- {IMPL: elisp}
2424
- {IMPL: elixir}
25+
- {IMPL: elixir.2}
2526
- {IMPL: elm}
2627
- {IMPL: erlang, NO_SELF_HOST: 1} # step4 silent exit on "(DO 3)"
2728
- {IMPL: es6}

Makefile.impls

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ wasm_MODE = wasmtime
3333
#
3434

3535
IMPLS = ada ada.2 awk bash basic bbc-basic c c.2 chuck clojure coffee common-lisp cpp crystal cs d dart \
36-
elisp elixir elm erlang es6 factor fantom fennel forth fsharp go groovy gnu-smalltalk \
36+
elisp elixir elixir.2 elm erlang es6 factor fantom fennel forth fsharp go groovy gnu-smalltalk \
3737
guile hare haskell haxe hy io janet java java-truffle js jq julia kotlin latex3 livescript logo lua make mal \
3838
matlab miniMAL nasm nim objc objpascal ocaml perl perl6 php picolisp pike plpgsql \
3939
plsql powershell prolog ps purs python2 python3 r racket rexx rpython ruby ruby.2 rust scala scheme skew sml \
@@ -125,6 +125,7 @@ d_STEP_TO_PROG = impls/d/$($(1))
125125
dart_STEP_TO_PROG = impls/dart/$($(1)).dart
126126
elisp_STEP_TO_PROG = impls/elisp/$($(1)).el
127127
elixir_STEP_TO_PROG = impls/elixir/lib/mix/tasks/$($(1)).ex
128+
elixir.2_STEP_TO_PROG = impls/elixir.2/lib/steps/$($(1)).ex
128129
elm_STEP_TO_PROG = impls/elm/$($(1)).js
129130
erlang_STEP_TO_PROG = impls/erlang/$($(1))
130131
es6_STEP_TO_PROG = impls/es6/$($(1)).mjs

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ process guide](process/guide.md) there is also a [mal/make-a-lisp
4242
FAQ](docs/FAQ.md) where I attempt to answer some common questions.
4343

4444

45-
**3. Mal is implemented in 89 languages (95 different implementations and 118 runtime modes)**
45+
**3. Mal is implemented in 89 languages (96 different implementations and 119 runtime modes)**
4646

4747
| Language | Creator |
4848
| -------- | ------- |
@@ -63,7 +63,8 @@ FAQ](docs/FAQ.md) where I attempt to answer some common questions.
6363
| [Crystal](#crystal) | [Linda_pp](https://github.com/rhysd) |
6464
| [D](#d) | [Dov Murik](https://github.com/dubek) |
6565
| [Dart](#dart) | [Harry Terkelsen](https://github.com/hterkelsen) |
66-
| [Elixir](#elixir) | [Martin Ek](https://github.com/ekmartin) |
66+
| [Elixir](#elixir) | [Martin Ek](https://github.com/ekmartin) | [
67+
| [Elixir #2](#elixir2) | [Alessandro Cerruti](https://github.com/chrooti) |
6768
| [Elm](#elm) | [Jos van Bakel](https://github.com/c0deaddict) |
6869
| [Emacs Lisp](#emacs-lisp) | [Vasilij Schneidermann](https://github.com/wasamasa) |
6970
| [Erlang](#erlang) | [Nathan Fiedler](https://github.com/nlfiedler) |
@@ -445,6 +446,17 @@ mix stepX_YYY
445446
iex -S mix stepX_YYY
446447
```
447448

449+
### Elixir.2
450+
451+
The second Elixir implementation of mal has been tested with Elixir 1.19.5 and Erlang/OTP 28.
452+
453+
```
454+
cd impls/elixir.2
455+
STEP=stepX_YYY mix run
456+
# Or with readline/line editing functionality:
457+
STEP=stepX_YYY iex -S mix
458+
```
459+
448460
### Elm
449461

450462
The Elm implementation of mal has been tested with Elm 0.18.0

impls/elixir.2/.credo.exs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
%{
2+
configs: [
3+
%{
4+
name: "default",
5+
checks: %{
6+
disabled: [
7+
{Credo.Check.Readability.ModuleDoc, []},
8+
{Credo.Check.Refactor.CyclomaticComplexity, []}
9+
]
10+
}
11+
}
12+
]
13+
}

impls/elixir.2/.formatter.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Used by "mix format"
2+
[
3+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
4+
]

impls/elixir.2/.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover/
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps/
9+
10+
# Where third-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# Temporary files, for example, from tests.
14+
/tmp/
15+
16+
# If the VM crashes, it generates a dump, let's ignore it too.
17+
erl_crash.dump
18+
19+
# Also ignore archive artifacts (built via "mix archive.build").
20+
*.ez
21+
22+
# Ignore package tarball (built via "mix hex.build").
23+
mal-*.tar
24+
25+
/.elixir_ls

impls/elixir.2/.iex.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Mal.start_repl()

impls/elixir.2/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM ubuntu:24.04
2+
MAINTAINER Alessandro Cerruti <whisper@chrooti.org>
3+
LABEL org.opencontainers.image.source=https://github.com/kanaka/mal
4+
LABEL org.opencontainers.image.description="mal test container: Elixir.2"
5+
##########################################################
6+
# General requirements for testing or common across many
7+
# implementations
8+
##########################################################
9+
10+
RUN apt-get -y update
11+
12+
# Required for running tests
13+
RUN apt-get -y install make python3
14+
RUN ln -sf /usr/bin/python3 /usr/bin/python
15+
16+
# Some typical implementation and test requirements
17+
RUN apt-get -y install curl libreadline-dev libedit-dev
18+
19+
RUN mkdir -p /mal
20+
WORKDIR /mal
21+
22+
##########################################################
23+
# Specific implementation requirements
24+
##########################################################
25+
26+
# Elixir (14)
27+
RUN apt-get install -y erlang-dev elixir
28+
29+
USER 1000
30+
RUN mix local.hex --force

impls/elixir.2/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.PHONY: all
2+
all: | deps
3+
mix compile
4+
5+
deps:
6+
mix deps.get
7+
8+
lib/steps/*.ex: all
9+
10+
.PHONY: clean
11+
clean:
12+
mix clean
13+
rm -fr deps _build .elixir_ls

impls/elixir.2/lib/mal.ex

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
defmodule Mal do
2+
use Application
3+
4+
def start(_type, _args) do
5+
if not IEx.started?() do
6+
start_repl()
7+
end
8+
9+
{:ok, self()}
10+
end
11+
12+
def start_repl() do
13+
step =
14+
System.fetch_env!("STEP")
15+
|> String.split("_")
16+
|> Enum.map_join(&String.capitalize/1)
17+
18+
module_name = Module.safe_concat([Mal, step])
19+
module_name.start()
20+
end
21+
end

0 commit comments

Comments
 (0)