This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=> (defmacro locking-read | |
"Utility to lock a readLock from the read-write lock provided and put body part in a try expression body where | |
finally unlocks the lock." | |
[rwlock & body] | |
`(let [readlock (.readLock ~rwlock)] | |
(.lock readlock) | |
(try | |
(do ~body) | |
(finally (.unlock rwlock))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns test) | |
(defn foo [a] | |
{:pre [(> a 2)]} | |
(println a)) | |
(binding [*assert* false] | |
(println *assert*) | |
(foo 2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro matchfn | |
"Compiles a pattern match to a lambda that matches against it's parameters. | |
Patterns are analyzed and if no pattern contains varargs (&) then patterns will be split in to | |
different fn aritity overloads. If & is present in one or more patterns all arguments are captured | |
in to args seq and matching is done on it as ([pattern] :seq)." | |
[& body] | |
(let [fname (if (symbol? (first body)) (first body) nil) | |
cases (if fname (rest body) body) | |
pattern-expression (partition 2 cases) | |
pattern-varargs (some (fn [[pattern _]] (when-not (= :else pattern) (some (partial = '&) pattern))) pattern-expression)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
class Foo | |
{ | |
void foo() { writeln("foo1"); } | |
void foo() { writeln("foo2"); } | |
void bar() { writeln("bar"); } | |
}; | |
int main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module gl.gl; | |
enum : uint | |
{ | |
MAX_TESS_CONTROL_OUTPUT_COMPONENTS = 0x8E83, | |
ONE_MINUS_SRC_ALPHA = 0x0303, | |
STENCIL_BACK_FUNC = 0x8800, | |
AND_REVERSE = 0x1502, | |
.... | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.etree.ElementTree as ET | |
import string | |
core_3_0 = [ | |
"VERSION_1_0", | |
"VERSION_1_1", | |
"VERSION_1_2", | |
"VERSION_1_3", | |
"VERSION_1_4", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
{ | |
int foo; | |
} | |
int main() | |
{ | |
const Foo[] foo = [new Foo(), new Foo(), new Foo()]; | |
foo[0].foo= 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ReturnType!fn checkedgl(alias fn) (ParameterTypeTuple!fn params, string file = __FILE__, size_t line = __LINE__) | |
{ | |
scope(success) | |
{ | |
auto errorCode = gl.getError(); | |
if(errorCode != 0) | |
throw new GlException(errorCode, file, line); | |
} | |
return fn(params); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module test; | |
import std.stdio; | |
void foo(T)(T param) { static assert(false, "Not implemented"); } | |
void foo(T:float)(T param) { writeln(param); } | |
int main() | |
{ | |
foo!double(1); | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int coordIndex(char c)() pure nothrow | |
{ | |
switch(c) | |
{ | |
case 'x': return 0; | |
case 'y': return 1; | |
case 'z': return N > 2 ? 2 : -1; | |
case 'w': return N > 3 ? 3 : -1; | |
default: | |
return -1; |
OlderNewer