Skip to content

Instantly share code, notes, and snippets.

Traceback (most recent call last)
storebug.nim(33) storebug
storebug.nim(31) main
asyncdispatch.nim(1627) waitFor
asyncdispatch.nim(1208) poll
system.nim(2542) cb
asyncfutures.nim(125) fail
asyncfutures.nim(150) :anonymous
zerruntime.nim(368) :anonymous
asyncfutures.nim(125) fail
import re
{.experimental.}
{.this: it.}
using
it: string
proc say(it) = system.echo it
proc test(it) =
REM - Run the full testsuite; tests\testament\tester all
REM - Uncomment the list of changes in news.txt
REM - write a news ticker entry
REM - Update the version
REM - Generate the full docs; koch web0
REM - Generate the installers;
REM - Update the version in system.nim
REM - Test the installers
template ov1(a: int; b: untyped; s1: untyped) =
let b = 10
if a != 0:
s1
template ov1(a: int; b: untyped; s1, s2: untyped) =
let b = 11
if a != 0:
s1
else:
const CacheLineSize = 32 # true for most archs
type
Barrier = object
entered: int
cv: Semaphore # Semaphore takes 3 words at least
when sizeof(int) < 8:
cacheAlign: array[CacheLineSize-4*sizeof(int), byte]
left: int
cacheAlign2: array[CacheLineSize-sizeof(int), byte]
type
VTable = object
methodA: proc (this: MyObject; a, b: int)
methodB: proc (this: MyObject; a, b: string)
OtherObject = object
fieldA: int
fieldB: int
MyObject = object
vtab {.delegate(this).}: ptr VTable
@Araq
Araq / release.bat
Last active January 18, 2016 14:20
Release instructions
REM - Run the full testsuite; tests\testament\tester all
REM - Uncomment the list of changes in news.txt
REM - write a news ticker entry
REM - Update the version
REM - Generate the full docs; koch web0
REM - Generate the installers;
REM - Update the version in system.nim
REM - Test the installers
var
a: array[2, Thread[int]]
proc worker(x: int) =
while true:
echo x
createThread(a[0], worker, 1)
createThread(a[1], worker, 2)
@Araq
Araq / LL.rst
Last active May 30, 2024 13:00

This document describes how Lambda Lifting (LL) works. LL is responsible for transforming 'closures' into (environment, function) pairs.

The basic approach is that captured vars need to be put on the heap and that the calling chain needs to be explicitly modelled. Things to consider:

proc a =
  var v = 0
import threadpool, tables, strutils
var db {.threadvar.}: CountTable[string]
proc rawPut(key: string) =
inc(db, key)
proc rawInit() =
db = initCountTable[string]()