Skip to content

Instantly share code, notes, and snippets.

#[allow(unused_imports)]
use std::sync::Arc;
#[allow(unused_imports)]
use std::vec::IntoIter as VecIntoIter;
#[allow(unused_imports)]
use vulkano::device::Device;
#[allow(unused_imports)]
use vulkano::descriptor::descriptor::DescriptorDesc;
extern crate time;
#[derive(Debug, Clone)]
struct Vertex { position: [f32; 2], velocity: [f32; 2] }
fn main() {
let mut arr = vec![ Vertex { position: [0.0, 0.0], velocity: [0.0, 0.0] }; 200000 ];
var x : auto = 10
# Error: internal error: getTypeDescAux(tyExpr)
# No stack traceback available
# To create a stacktrace, rerun compilation with ./koch temp c <file>
import unittest
type memory* [T=byte] = distinct ptr T
proc `+`*[T](mem: memory[T]; offset: int): memory[T] =
cast[memory[T]](cast[int](mem) + offset*sizeof(T))
proc `-`*[T](mem: memory[T]; offset: int): memory[T] =
cast[memory[T]](cast[int](mem) - offset*sizeof(T))
proc incval(x: string; y: string): string =
"completely unrelated"
proc test(): tuple[incval: proc(); getval: proc():int] =
var val = 0
proc incval() =
inc val
{.experimental.}
type Mat2F
[
rowCount, colCount: static[int];
elementType
] =
object ## A 2-dimensional fixed-sized matrix of an arbitrary type
elementList: array[rowCount*colCount, elementType]
@Deco
Deco / aahh.nim
Last active August 29, 2015 14:15
import unittest, typetraits
suite "aahh":
test "aahh":
var a = 5
let cond = (name(type(a)) == "int")
require(cond) # works
import sequtils
template test(x: int; list: varargs[int]): expr =
foldl(list, a*(b+x))
echo test(5, 1, 2, 3, 4) # 504
import memory
type MatD*[ElementT] = tuple
elementCount: uint32
dimensionCount: uint16
data: memory[byte]
template matD(dimensions: varargs[float64]; elementT: typedesc): expr =
type MatF[ElementT, PLEASE_HELP] = object
data: array[SOME_VARIABLE_LENGTH_HERE, ElementT]
template matF*(elementT: typedesc; dimensions: varargs[int]): expr =
let dimensionCount = len(dimensions)
let elementCount = foldl(dimensions, a*b)
???