Skip to content

Instantly share code, notes, and snippets.

@ragnard
ragnard / routify-breadcrumds.md
Last active Mar 4, 2021
Routify Breadcrumbs
View routify-breadcrumds.md

Scenario

Let's say I have something like this:

src/pages/foo/index.svelte

  • a page listing some foos
View reify.clj
(Thread. (reify Runnable
(run [] (println "Running!"))))
@ragnard
ragnard / JavaFX.java
Last active Oct 10, 2017
Clojure and static class initialization
View JavaFX.java
import javafx.scene.control.Cell;
public class JavaFX {
public static Class f() {
return Cell.class;
}
}
@ragnard
ragnard / gist:94e5838c860e80ec97b00dff95510395
Created Aug 28, 2017
ImageSingletons do not contain key com.oracle.svm.graal.GraalSupport
View gist:94e5838c860e80ec97b00dff95510395
$ ~/projects/graalvm/graalvm-0.27/bin/native-image -cp com.github.ragnard.shentruffle.klambda/target/classes:com.github.ragnard.shentruffle.shen/target/classes com.github.ragnard.shentruffle.KLambda
classlist: 1,761.15 ms
(cap): 960.01 ms
setup: 1,509.68 ms
analysis: 2,407.04 ms
fatal error: org.graalvm.compiler.java.BytecodeParser$BytecodeParserError: com.oracle.svm.core.util.UserError$UserException: ImageSingletons do not contain key com.oracle.svm.graal.GraalSupport
at parsing com.oracle.svm.graal.GraalSupport.get(GraalSupport.java:235)
at org.graalvm.compiler.java.BytecodeParser.asParserError(BytecodeParser.java:2157)
at org.graalvm.compiler.java.BytecodeParser.iterateBytecodesForBlock(BytecodeParser.java:2840)
at org.graalvm.compiler.java.BytecodeParser.processBlock(BytecodeParser.java:2659)
@ragnard
ragnard / count-down.lisp
Last active Aug 17, 2017
tail recursion
View count-down.lisp
(defun count-down (n)
(if (= n 0)
done
(count-down (- n 1))))
(count-down 1000000)
(count-down 1000000)
(count-down 1000000)
(count-down 1000000)
(count-down 1000000)
View shen-truffle.log
$ ./scripts/shen-truffle
Loading toplevel.kl
Loading core.kl
Loading sys.kl
Loading sequent.kl
Loading yacc.kl
Loading reader.kl
Loading prolog.kl
Loading track.kl
Loading load.kl
View gist:52ea88259d3565736094fb90feadc381
$ mvn compile
...
$ ./scripts/kl --dump < tests/kl/count-down.kl
@ragnard
ragnard / count-down.lisp
Last active Aug 15, 2017
klambda recursion
View count-down.lisp
(defun count-down (N)
(if (= N 0)
done
(count-down (- N 1))))
View arity.md

Arity and dispatch

  • functions have a single, known arity

Given a function f, with arity 3 (lambda (a b c) ...), application can be performed in three ways:

partial application: (f 1)

  • return curried function with arity 2

exact application: (f 1 2 3)

View gist:c5a13c7db9a668a445f1073c61ce46ea
$ time ./truffleshen '(+ 1 2)'
Loading toplevel.kl
Loading core.kl
Loading sys.kl
Loading sequent.kl
Loading yacc.kl
Loading reader.kl
Loading prolog.kl
Loading track.kl
Loading load.kl