aboutsummaryrefslogtreecommitdiff
path: root/src/lambda.rs
diff options
context:
space:
mode:
authorTill Höppner2016-02-23 17:00:53 +0100
committerTill Höppner2016-02-24 18:36:04 +0100
commitf01c278a26e0f248d188c10bdb852b0859b98b3b (patch)
tree3e729bf243011111a20b84f24aea3fbcb9f595f5 /src/lambda.rs
parent815f31f5cef61709c50087c9f7601ea330929bb7 (diff)
downloadilc-f01c278a26e0f248d188c10bdb852b0859b98b3b.tar.gz
ilc-f01c278a26e0f248d188c10bdb852b0859b98b3b.tar.xz
ilc-f01c278a26e0f248d188c10bdb852b0859b98b3b.zip
Test CI
Diffstat (limited to 'src/lambda.rs')
-rw-r--r--src/lambda.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lambda.rs b/src/lambda.rs
new file mode 100644
index 0000000..cf7b1ec
--- /dev/null
+++ b/src/lambda.rs
@@ -0,0 +1,18 @@
+// I'm only a little sorry for this.
+
+// Inline definition of anonymous functions. Examples:
+// l!(42;)
+// l!(i32 := 42)
+// l!(i: i32 := i + 42)
+// l!(i: i32, j: i32 -> i32 := i + j)
+#[macro_export]
+macro_rules! l {
+ ($body: expr) => ({ fn f() { $body } f });
+ ($res: ty := $body: expr) => ({ fn f() -> $res { $body } f });
+ ($($n: ident: $t: ty),+ := $body: expr) => ({
+ fn f($($n: $t),+) { $body } f
+ });
+ ($($n: ident: $t: ty),+ -> $res: ty := $body: expr) => ({
+ fn f($($n: $t),+) -> $res { $body } f
+ })
+}