Skip to content

Commit 03769f1

Browse files
Add Tcl programming language (#742)
* start work on adding Tcl * fix looping example * add svg logo * use currentColor as fill for the Tcl logo * workaround for "can't find usable init.tcl'" error * fix version typo * Remove the wrapper Closes #130 Co-authored-by: James Raspass <jraspass@gmail.com>
1 parent 60e8e3b commit 03769f1

File tree

10 files changed

+63
-4
lines changed

10 files changed

+63
-4
lines changed

build-langs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ for %langs{ @langs || * }:p.sort -> (:key($name), :value(%lang)) {
4040
%lang<version> = $id eq 'assembly' ?? "DefAssembler $0" !! $0;
4141
}
4242
else {
43-
( my $proc = run «docker run --rm --tmpfs '/tmp:exec' $img», :out ).sink;
43+
my $proc = run «docker run -i --rm --tmpfs '/tmp:exec' $img», :in, :out;
44+
45+
$proc.in.say: 'puts [info patchlevel]' if $id eq 'tcl';
46+
$proc.in.close;
4447

4548
my $ver = $proc.out.slurp(:close).chomp.trans: "\n" => ' ';
4649

config/langs.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,25 @@ for arg in CommandLine.arguments[1...] {
803803
}
804804
'''
805805

806+
[Tcl]
807+
size = '2.44 MiB'
808+
version = '8.6.12'
809+
website = 'https://www.tcl-lang.org'
810+
example = '''
811+
# Printing
812+
puts "Hello, World!"
813+
814+
# Looping
815+
for {set x 0} {$x < 10} {incr x} {
816+
puts $x
817+
}
818+
819+
# Accessing arguments
820+
foreach arg $argv {
821+
puts $arg
822+
}
823+
'''
824+
806825
[V]
807826
size = '38.5 MiB'
808827
version = '0.2.4'

css/golfer/holes.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ input.rust:not(:checked) ~ .rust,
8585
input.sed:not(:checked) ~ .sed,
8686
input.sql:not(:checked) ~ .sql,
8787
input.swift:not(:checked) ~ .swift,
88+
input.tcl:not(:checked) ~ .tcl,
8889
input.v:not(:checked) ~ .v,
8990
input.viml:not(:checked) ~ .viml,
9091
input.wren:not(:checked) ~ .wren,
@@ -113,7 +114,7 @@ main svg:nth-of-type(2) {
113114

114115
@media (min-width: 95rem) {
115116
/* Increase this number when adding a language. */
116-
main { grid-template-columns: 6fr repeat(42, 1fr) }
117+
main { grid-template-columns: 6fr repeat(43, 1fr) }
117118

118119
main a { height: 1.9rem }
119120

db/a-schema.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ CREATE TYPE lang AS ENUM (
5151
'crystal', 'd', 'elixir', 'f-sharp', 'fish', 'fortran', 'go',
5252
'golfscript', 'haskell', 'hexagony', 'j', 'java', 'javascript', 'julia',
5353
'k', 'lisp', 'lua', 'nim', 'pascal', 'perl', 'php', 'powershell',
54-
'prolog', 'python', 'raku', 'ruby', 'rust', 'sed', 'sql', 'swift', 'v',
55-
'viml', 'wren', 'zig'
54+
'prolog', 'python', 'raku', 'ruby', 'rust', 'sed', 'sql', 'swift', 'tcl',
55+
'v', 'viml', 'wren', 'zig'
5656
);
5757

5858
CREATE TYPE medal AS ENUM ('diamond', 'gold', 'silver', 'bronze');

docker/dev.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ COPY --from=codegolf/lang-fish ["/", "/langs/fish/rootfs/" ] # 4.99 M
4141
COPY --from=codegolf/lang-j ["/", "/langs/j/rootfs/" ] # 4.84 MiB
4242
COPY --from=codegolf/lang-brainfuck ["/", "/langs/brainfuck/rootfs/" ] # 4.57 MiB
4343
COPY --from=codegolf/lang-cobol ["/", "/langs/cobol/rootfs/" ] # 4.09 MiB
44+
COPY --from=codegolf/lang-tcl ["/", "/langs/tcl/rootfs/" ] # 2.44 MiB
4445
COPY --from=codegolf/lang-c ["/", "/langs/c/rootfs/" ] # 1.61 MiB
4546
COPY --from=codegolf/lang-bash ["/", "/langs/bash/rootfs/" ] # 1.19 MiB
4647
COPY --from=codegolf/lang-sql ["/", "/langs/sql/rootfs/" ] # 1.11 MiB

docker/live.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ COPY --from=codegolf/lang-fish ["/", "/langs/fish/rootfs/" ] # 4.99 M
5454
COPY --from=codegolf/lang-j ["/", "/langs/j/rootfs/" ] # 4.84 MiB
5555
COPY --from=codegolf/lang-brainfuck ["/", "/langs/brainfuck/rootfs/" ] # 4.57 MiB
5656
COPY --from=codegolf/lang-cobol ["/", "/langs/cobol/rootfs/" ] # 4.09 MiB
57+
COPY --from=codegolf/lang-tcl ["/", "/langs/tcl/rootfs/" ] # 2.44 MiB
5758
COPY --from=codegolf/lang-c ["/", "/langs/c/rootfs/" ] # 1.61 MiB
5859
COPY --from=codegolf/lang-bash ["/", "/langs/bash/rootfs/" ] # 1.19 MiB
5960
COPY --from=codegolf/lang-sql ["/", "/langs/sql/rootfs/" ] # 1.11 MiB

hole/play.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ func play(ctx context.Context, holeID, langID, code string, score *Scorecard) {
255255
cmd.Args = []string{"/usr/bin/sed", "-E", "-z", "--sandbox", "-u", "--", code}
256256
case "swift":
257257
cmd.Args = []string{"/usr/bin/swift", "-module-cache-path", "/tmp", "-"}
258+
case "tcl":
259+
cmd.Args = []string{"/usr/bin/tcl", "/proc/self/fd/0"}
258260
default:
259261
cmd.Args = []string{"/usr/bin/" + langID, "-"}
260262
}

langs/tcl/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM alpine:3.16 AS builder
2+
3+
RUN apk add --no-cache build-base curl
4+
5+
RUN curl -L https://github.com/tcltk/tcl/archive/refs/tags/core-8-6-12.tar.gz | tar xz
6+
7+
RUN touch /empty
8+
9+
RUN cd tcl-core-8-6-12/unix \
10+
&& ./configure \
11+
--disable-load \
12+
--disable-symbols \
13+
--disable-shared \
14+
--enable-64-bit \
15+
&& make \
16+
&& strip tclsh
17+
18+
FROM codegolf/lang-base
19+
20+
COPY --from=builder /lib/ld-musl-x86_64.so.1 /lib/
21+
COPY --from=builder tcl-core-8-6-12/unix/tclsh /usr/bin/tcl
22+
23+
# Create empty init.tcl to avoid "can't find usable init.tcl" error
24+
COPY --from=builder /empty /library/init.tcl
25+
26+
ENTRYPOINT ["tcl"]

latest-langs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ constant @urls = (
3333
'Rust' => 'Rust_(programming_language)',
3434
'SQL' => 'SQLite',
3535
'Swift' => 'Swift_(programming_language)',
36+
'Tcl' => 'Tcl',
3637
'VimL' => 'Vim_(text_editor)',
3738
'Zig' => 'Zig_(programming_language)',
3839
);

svg/tcl.svg

Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)